[FFmpeg-devel] [PATCH] Implement PAFF in H.264
Jeff Downs
heydowns
Fri Sep 21 18:06:32 CEST 2007
On Thu, 20 Sep 2007, Martin Zlomek wrote:
> The attached patch fixes CurrPicNum of short term reference fields/frames
> in reference picture list reordering.
>
> --- h264.c.orig 2007-09-20 23:30:38.000000000 +0200
> +++ h264.c 2007-09-20 23:30:53.000000000 +0200
> @@ -3056,6 +3056,9 @@
> add = 0;
> }
>
> + if (pred > h->curr_pic_num)
> + pred -= h->max_pic_num;
> +
> for(i= h->short_ref_count-1; i>=0; i--){
> ref = h->short_ref[i];
> assert(ref->reference == 3);
This doesn't look right -- shouldn't the wrap check come prior to the
block at the start of the patch? At this point of insertion, frame number
to look for has already been determined. Also, pred value can't be
modified like this; it can be used in subsequent iterations of the loop
and has to retain the unmodified value.
This is actually not intimately tied to PAFF support; this was there all
along so I'm guessing this should be kept distinct from the PAFF support
patches.
So, the attached patch is one more to add, to be applied after the
PAFF patches. A different (smaller) patch is needed if we want to fix
prior to PAFF.
-Jeff
-------------- next part --------------
--- h264-lastpost.c 2007-09-21 10:05:05.000000000 -0400
+++ h264.c 2007-09-21 10:09:50.000000000 -0400
@@ -3055,6 +3055,7 @@
if(reordering_of_pic_nums_idc<2){
const unsigned int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
int frame_num;
+ int pic_num;
if(abs_diff_pic_num >= h->max_pic_num){
av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
@@ -3064,10 +3065,14 @@
if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;
else pred+= abs_diff_pic_num;
pred &= h->max_pic_num - 1;
+
+ pic_num = pred;
+ if (pic_num > h->curr_pic_num)
+ pic_num -= h->max_pic_num;
if (FIELD_PICTURE) {
- frame_num = pred >> 1;
- if (pred & 1) {
+ frame_num = pic_num >> 1;
+ if (pic_num & 1) {
pic_structure = s->picture_structure;
add = (s->picture_structure == PICT_BOTTOM_FIELD);
} else {
@@ -3075,7 +3080,7 @@
add = (s->picture_structure == PICT_TOP_FIELD);
}
} else {
- frame_num = pred;
+ frame_num = pic_num;
pic_structure = PICT_FRAME;
add = 0;
}
@@ -3091,7 +3096,7 @@
break;
}
if(i>=0)
- ref->pic_id= pred;
+ ref->pic_id= pic_num;
}else{
int long_idx;
pic_id= get_ue_golomb(&s->gb); //long_term_pic_idx
More information about the ffmpeg-devel
mailing list