Commit 7f92f3d8 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  h264: fix frame reordering code.
  fate: Add a test for the VBLE decoder
  doc: break some long lines in developer.texi
  drawtext: make x and y parametric
  drawtext: manage memory allocation better
  drawtext: refactor draw_text
  doc: remove space between variable and post increment in example code

Conflicts:
	doc/developer.texi
	doc/filters.texi
	libavcodec/h264.c
	libavfilter/vf_drawtext.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents ff53c79d adedd840
......@@ -64,7 +64,8 @@ The TAB character is forbidden outside of Makefiles as is any
form of trailing whitespace. Commits containing either will be
rejected by the git repository.
@item
You should try to limit your code lines to 80 characters; however, do so if and only if this improves readability.
You should try to limit your code lines to 80 characters; however, do so if
and only if this improves readability.
@end itemize
The presentation is one inspired by 'indent -i4 -kr -nut'.
......@@ -144,6 +145,7 @@ All names are using underscores (_), not CamelCase. For example, @samp{avfilter_
a valid function name and @samp{AVFilterGetVideo} is not. The exception from this are type names, like
for example structs and enums; they should always be in the CamelCase
There are following conventions for naming variables and functions:
@itemize @bullet
@item
......@@ -151,13 +153,15 @@ For local variables no prefix is required.
@item
For variables and functions declared as @code{static} no prefixes are required.
@item
For variables and functions used internally by the library, @code{ff_} prefix should be used.
For variables and functions used internally by the library, @code{ff_} prefix
should be used.
For example, @samp{ff_w64_demuxer}.
@item
For variables and functions used internally across multiple libraries, use @code{avpriv_}. For example,
@samp{avpriv_aac_parse_header}.
For variables and functions used internally across multiple libraries, use
@code{avpriv_}. For example, @samp{avpriv_aac_parse_header}.
@item
For exported names, each library has its own prefixes. Just check the existing code and name accordingly.
For exported names, each library has its own prefixes. Just check the existing
code and name accordingly.
@end itemize
@subsection Miscellanous conventions
......
......@@ -1770,6 +1770,7 @@ other parameters is 0.
These parameters correspond to the parameters assigned to the
libopencv function @code{cvSmooth}.
@anchor{overlay}
@section overlay
Overlay one video on top of another.
......
......@@ -1381,6 +1381,7 @@ static void decode_postinit(H264Context *h, int setup_finished){
Picture *out = s->current_picture_ptr;
Picture *cur = s->current_picture_ptr;
int i, pics, out_of_order, out_idx;
int invalid = 0, cnt = 0;
s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_H264;
s->current_picture_ptr->f.pict_type = s->pict_type;
......@@ -1475,25 +1476,6 @@ static void decode_postinit(H264Context *h, int setup_finished){
s->low_delay= 0;
}
for (i = 0; 1; i++) {
if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
if(i)
h->last_pocs[i-1] = cur->poc;
break;
} else if(i) {
h->last_pocs[i-1]= h->last_pocs[i];
}
}
out_of_order = MAX_DELAYED_PIC_COUNT - i;
if( cur->f.pict_type == AV_PICTURE_TYPE_B
|| (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2))
out_of_order = FFMAX(out_of_order, 1);
if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){
av_log(s->avctx, AV_LOG_WARNING, "Increasing reorder buffer to %d\n", out_of_order);
s->avctx->has_b_frames = out_of_order;
s->low_delay = 0;
}
pics = 0;
while(h->delayed_pic[pics]) pics++;
......@@ -1503,30 +1485,86 @@ static void decode_postinit(H264Context *h, int setup_finished){
if (cur->f.reference == 0)
cur->f.reference = DELAYED_PIC_REF;
/* Frame reordering. This code takes pictures from coding order and sorts
* them by their incremental POC value into display order. It supports POC
* gaps, MMCO reset codes and random resets.
* A "display group" can start either with a IDR frame (f.key_frame = 1),
* and/or can be closed down with a MMCO reset code. In sequences where
* there is no delay, we can't detect that (since the frame was already
* output to the user), so we also set h->mmco_reset to detect the MMCO
* reset code.
* FIXME: if we detect insufficient delays (as per s->avctx->has_b_frames),
* we increase the delay between input and output. All frames affected by
* the lag (e.g. those that should have been output before another frame
* that we already returned to the user) will be dropped. This is a bug
* that we will fix later. */
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) {
cnt += out->poc < h->last_pocs[i];
invalid += out->poc == INT_MIN;
}
if (!h->mmco_reset && !cur->f.key_frame && cnt + invalid == MAX_DELAYED_PIC_COUNT && cnt > 0) {
h->mmco_reset = 2;
if (pics > 1)
h->delayed_pic[pics - 2]->mmco_reset = 2;
}
if (h->mmco_reset || cur->f.key_frame) {
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
cnt = 0;
invalid = MAX_DELAYED_PIC_COUNT;
}
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1; h->delayed_pic[i] && !h->delayed_pic[i]->f.key_frame && !h->delayed_pic[i]->mmco_reset; i++)
for (i = 1; i < MAX_DELAYED_PIC_COUNT && h->delayed_pic[i] &&
!h->delayed_pic[i-1]->mmco_reset && !h->delayed_pic[i]->f.key_frame; i++)
{
if(h->delayed_pic[i]->poc < out->poc){
out = h->delayed_pic[i];
out_idx = i;
}
if (s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset))
h->next_outputed_poc= INT_MIN;
out_of_order = out->poc < h->next_outputed_poc;
}
if (s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->f.key_frame || h->mmco_reset))
h->next_outputed_poc = INT_MIN;
out_of_order = !out->f.key_frame && !h->mmco_reset && (out->poc < h->next_outputed_poc);
if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames)
{ }
else if (out_of_order && pics-1 == s->avctx->has_b_frames &&
s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) {
if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
s->avctx->has_b_frames = FFMAX(s->avctx->has_b_frames, cnt);
av_log(0,0, "hbf: %d\n", s->avctx->has_b_frames );
}
s->low_delay = 0;
} else if (s->low_delay &&
((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2) ||
cur->f.pict_type == AV_PICTURE_TYPE_B)) {
s->low_delay = 0;
s->avctx->has_b_frames++;
}
if(out_of_order || pics > s->avctx->has_b_frames){
if(pics > s->avctx->has_b_frames){
out->f.reference &= ~DELAYED_PIC_REF;
out->owner2 = s; // for frame threading, the owner must be the second field's thread
// or else the first thread can release the picture and reuse it unsafely
for(i=out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i+1];
}
memmove(h->last_pocs, &h->last_pocs[1], sizeof(*h->last_pocs) * (MAX_DELAYED_PIC_COUNT - 1));
h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] = cur->poc;
if(!out_of_order && pics > s->avctx->has_b_frames){
h->next_output_pic = out;
if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
h->next_outputed_poc = INT_MIN;
} else
if (out->mmco_reset) {
if (out_idx > 0) {
h->next_outputed_poc = out->poc;
h->delayed_pic[out_idx - 1]->mmco_reset = out->mmco_reset;
} else {
h->next_outputed_poc = INT_MIN;
}
} else {
h->next_outputed_poc = out->poc;
}
h->mmco_reset = 0;
}else{
av_log(s->avctx, AV_LOG_DEBUG, "no picture\n");
}
......@@ -2385,6 +2423,8 @@ static void flush_dpb(AVCodecContext *avctx){
h->delayed_pic[i]->f.reference = 0;
h->delayed_pic[i]= NULL;
}
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
h->outputed_poc=h->next_outputed_poc= INT_MIN;
h->prev_interlaced_frame = 1;
idr(h);
......
......@@ -500,6 +500,7 @@ typedef struct H264Context{
*/
MMCO mmco[MAX_MMCO_COUNT];
int mmco_index;
int mmco_reset;
int long_ref_count; ///< number of actual long term references
int short_ref_count; ///< number of actual short term references
......
......@@ -582,13 +582,9 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
for(j = 0; j < 16; j++) {
remove_long(h, j, 0);
}
s->current_picture_ptr->poc=
s->current_picture_ptr->field_poc[0]=
s->current_picture_ptr->field_poc[1]=
h->poc_lsb=
h->poc_msb=
h->frame_num=
s->current_picture_ptr->frame_num= 0;
h->mmco_reset = 1;
s->current_picture_ptr->mmco_reset=1;
break;
default: assert(0);
......
......@@ -345,8 +345,8 @@ fate-h264-conformance-mps_mw_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-confo
fate-h264-conformance-mr1_bt_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR1_BT_A.h264
fate-h264-conformance-mr1_mw_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR1_MW_A.264
fate-h264-conformance-mr2_mw_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR2_MW_A.264
fate-h264-conformance-mr2_tandberg_e: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR2_TANDBERG_E.264
fate-h264-conformance-mr3_tandberg_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR3_TANDBERG_B.264
fate-h264-conformance-mr2_tandberg_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR2_TANDBERG_E.264
fate-h264-conformance-mr3_tandberg_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR3_TANDBERG_B.264
fate-h264-conformance-mr4_tandberg_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR4_TANDBERG_C.264
fate-h264-conformance-mr5_tandberg_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR5_TANDBERG_C.264
fate-h264-conformance-mr6_bt_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR6_BT_B.h264
......
......@@ -238,3 +238,6 @@ fate-musepack7: FUZZ = 1
FATE_TESTS += fate-iirfilter
fate-iirfilter: libavcodec/iirfilter-test$(EXESUF)
fate-iirfilter: CMD = run libavcodec/iirfilter-test
FATE_TESTS += fate-vble
fate-vble: CMD = framecrc -i $(SAMPLES)/vble/flowers-partial-2MB.avi
0, 0, 1382400, 0x5e1bc307
0, 3003, 1382400, 0x198795f7
0, 6006, 1382400, 0xa9102ac2
0, 9009, 1382400, 0x9e347932
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment