@@ -60,7 +60,7 @@ const uint16_t ff_h264_mb_sizes[4] = { 256, 384, 512, 768 };
int avpriv_h264_has_num_reorder_frames (AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data ;
return h ? h->sps . num_reorder_frames : 0 ;
return h && h->ps . sps ? h-> ps . sps -> num_reorder_frames : 0 ;
}
static void h264_er_decode_mb (void *opaque, int ref, int mv_dir, int mv_type,
@@ -419,17 +419,11 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
int i;
h->avctx = avctx;
<<<<<<< HEAD
h->backup_width = -1 ;
h->backup_height = -1 ;
h->backup_pix_fmt = AV_PIX_FMT_NONE;
h->dequant_coeff_pps = -1 ;
h->current_sps_id = -1 ;
h->cur_chroma_format_idc = -1 ;
||||||| merged common ancestors
h->dequant_coeff_pps = -1 ;
=======
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
h->picture_structure = PICT_FRAME;
h->slice_context_count = 1 ;
@@ -643,13 +637,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
/* Derive top_field_first from field pocs. */
cur->f ->top_field_first = cur->field_poc [0 ] < cur->field_poc [1 ];
} else {
<<<<<<< HEAD
if (h->sps .pic_struct_present_flag ) {
||||||| merged common ancestors
if (cur->f ->interlaced_frame || h->sps .pic_struct_present_flag ) {
=======
if (cur->f ->interlaced_frame || sps->pic_struct_present_flag ) {
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
if (sps->pic_struct_present_flag ) {
/* Use picture timing SEI information. Even if it is a
* information of a past frame, better than nothing. */
if (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||
@@ -746,19 +734,9 @@ static void decode_postinit(H264Context *h, int setup_finished)
// FIXME do something with unavailable reference frames
/* Sort B-frames into display order */
<<<<<<< HEAD
if (h->sps .bitstream_restriction_flag ||
h->avctx ->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
h->avctx ->has_b_frames = FFMAX (h->avctx ->has_b_frames , h->sps .num_reorder_frames );
||||||| merged common ancestors
if (h->sps .bitstream_restriction_flag ||
h->avctx ->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
h->avctx ->has_b_frames = FFMAX (h->avctx ->has_b_frames , h->sps .num_reorder_frames );
=======
if (sps->bitstream_restriction_flag ||
h->avctx ->strict_std_compliance >= FF_COMPLIANCE_NORMAL ) {
h->avctx ->strict_std_compliance >= FF_COMPLIANCE_STRICT ) {
h->avctx ->has_b_frames = FFMAX (h->avctx ->has_b_frames , sps->num_reorder_frames );
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
}
h->low_delay = !h->avctx ->has_b_frames ;
@@ -781,7 +759,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
h->last_pocs [i] = INT_MIN;
h->last_pocs [0 ] = cur->poc ;
cur->mmco_reset = 1 ;
} else if (h->avctx ->has_b_frames < out_of_order && !h-> sps . bitstream_restriction_flag ){
} else if (h->avctx ->has_b_frames < out_of_order && !sps-> bitstream_restriction_flag ){
av_log (h->avctx , AV_LOG_INFO, " Increasing reorder buffer to %d \n " , out_of_order);
h->avctx ->has_b_frames = out_of_order;
h->low_delay = 0 ;
@@ -810,47 +788,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
if (h->avctx ->has_b_frames == 0 &&
(h->delayed_pic [0 ]->f ->key_frame || h->delayed_pic [0 ]->mmco_reset ))
h->next_outputed_poc = INT_MIN;
<<<<<<< HEAD
out_of_order = out->poc < h->next_outputed_poc ;
||||||| merged common ancestors
out_of_order = !out->f ->key_frame && !h->mmco_reset &&
(out->poc < h->next_outputed_poc );
if (h->sps .bitstream_restriction_flag &&
h->avctx ->has_b_frames >= h->sps .num_reorder_frames ) {
} else if (out_of_order && pics - 1 == h->avctx ->has_b_frames &&
h->avctx ->has_b_frames < MAX_DELAYED_PIC_COUNT) {
if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
h->avctx ->has_b_frames = FFMAX (h->avctx ->has_b_frames , cnt);
}
h->low_delay = 0 ;
} else if (h->low_delay &&
((h->next_outputed_poc != INT_MIN &&
out->poc > h->next_outputed_poc + 2 ) ||
cur->f ->pict_type == AV_PICTURE_TYPE_B)) {
h->low_delay = 0 ;
h->avctx ->has_b_frames ++;
}
=======
out_of_order = !out->f ->key_frame && !h->mmco_reset &&
(out->poc < h->next_outputed_poc );
if (sps->bitstream_restriction_flag &&
h->avctx ->has_b_frames >= sps->num_reorder_frames ) {
} else if (out_of_order && pics - 1 == h->avctx ->has_b_frames &&
h->avctx ->has_b_frames < MAX_DELAYED_PIC_COUNT) {
if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
h->avctx ->has_b_frames = FFMAX (h->avctx ->has_b_frames , cnt);
}
h->low_delay = 0 ;
} else if (h->low_delay &&
((h->next_outputed_poc != INT_MIN &&
out->poc > h->next_outputed_poc + 2 ) ||
cur->f ->pict_type == AV_PICTURE_TYPE_B)) {
h->low_delay = 0 ;
h->avctx ->has_b_frames ++;
}
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
if (out_of_order || pics > h->avctx ->has_b_frames ) {
out->reference &= ~DELAYED_PIC_REF;
@@ -1209,27 +1147,17 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
if ((err = ff_h264_decode_slice_header (h, sl)))
break ;
<<<<<<< HEAD
if (h->sei_recovery_frame_cnt >= 0 ) {
if (h->frame_num != h->sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
h->valid_recovery_point = 1 ;
if ( h->recovery_frame < 0
|| av_mod_uintp2 (h->recovery_frame - h->frame_num , h->sps . log2_max_frame_num ) > h->sei_recovery_frame_cnt ) {
h->recovery_frame = av_mod_uintp2 (h->frame_num + h->sei_recovery_frame_cnt , h->sps . log2_max_frame_num );
|| av_mod_uintp2 (h->recovery_frame - h->frame_num , h->ps . sps -> log2_max_frame_num ) > h->sei_recovery_frame_cnt ) {
h->recovery_frame = av_mod_uintp2 (h->frame_num + h->sei_recovery_frame_cnt , h->ps . sps -> log2_max_frame_num );
if (!h->valid_recovery_point )
h->recovery_frame = h->frame_num ;
}
||||||| merged common ancestors
if (h->sei_recovery_frame_cnt >= 0 && h->recovery_frame < 0 ) {
h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt ) &
((1 << h->sps .log2_max_frame_num ) - 1 );
=======
if (h->sei_recovery_frame_cnt >= 0 && h->recovery_frame < 0 ) {
h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt ) &
((1 << h->ps .sps ->log2_max_frame_num ) - 1 );
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
}
h->cur_pic_ptr ->f ->key_frame |= (nal->type == NAL_IDR_SLICE);
@@ -1295,30 +1223,18 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
if (ret < 0 && (h->avctx ->err_recognition & AV_EF_EXPLODE))
goto end;
break ;
case NAL_SPS:
<<<<<<< HEAD
h->gb = nal->gb ;
if (ff_h264_decode_seq_parameter_set (h, 0 ) >= 0 )
case NAL_SPS: {
GetBitContext tmp_gb = nal->gb ;
if (ff_h264_decode_seq_parameter_set (&tmp_gb, avctx, &h->ps , 0 ) >= 0 )
break ;
av_log (h->avctx , AV_LOG_DEBUG,
" SPS decoding failure, trying again with the complete NAL\n " );
init_get_bits8 (&h-> gb , nal->raw_data + 1 , nal->raw_size - 1 );
if (ff_h264_decode_seq_parameter_set (h , 0 ) >= 0 )
init_get_bits8 (&tmp_gb , nal->raw_data + 1 , nal->raw_size - 1 );
if (ff_h264_decode_seq_parameter_set (&tmp_gb, avctx, &h-> ps , 0 ) >= 0 )
break ;
h->gb = nal->gb ;
ff_h264_decode_seq_parameter_set (h, 1 );
||||||| merged common ancestors
h->gb = nal->gb ;
ret = ff_h264_decode_seq_parameter_set (h);
if (ret < 0 && (h->avctx ->err_recognition & AV_EF_EXPLODE))
goto end;
=======
ret = ff_h264_decode_seq_parameter_set (&nal->gb , avctx, &h->ps );
if (ret < 0 && (h->avctx ->err_recognition & AV_EF_EXPLODE))
goto end;
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
ff_h264_decode_seq_parameter_set (&nal->gb , avctx, &h->ps , 1 );
break ;
}
case NAL_PPS:
ret = ff_h264_decode_picture_parameter_set (&nal->gb , avctx, &h->ps ,
nal->size_bits );
@@ -1386,7 +1302,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
* past end by one (callers fault) and resync_mb_y != 0
* causes problems for the first MB line, too.
*/
if (!FIELD_PICTURE (h) && h->current_slice && !h->sps .new && h->enable_er ) {
if (!FIELD_PICTURE (h) && h->current_slice &&
h->ps .sps == (const SPS*)h->ps .sps_list [h->ps .pps ->sps_id ]->data &&
h->enable_er ) {
H264SliceContext *sl = h->slice_ctx ;
int use_last_pic = h->last_pic_for_ec .f ->buf [0 ] && !sl->ref_count [0 ];
@@ -1444,7 +1363,6 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
if (ret < 0 )
return ret;
<<<<<<< HEAD
av_dict_set (&dst->metadata , " stereo_mode" , ff_h264_sei_stereo_mode (h), 0 );
h->backup_width = h->avctx ->width ;
@@ -1458,32 +1376,13 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
if (srcp->sei_recovery_frame_cnt == 0 )
dst->key_frame = 1 ;
if (!srcp->crop )
||||||| merged common ancestors
if (!h->sps .crop )
=======
if (!h->ps .sps || !h->ps .sps ->crop )
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
return 0 ;
<<<<<<< HEAD
for (i = 0 ; i < desc->nb_components ; i++) {
int hshift = (i > 0 ) ? desc->log2_chroma_w : 0 ;
int vshift = (i > 0 ) ? desc->log2_chroma_h : 0 ;
int off = ((srcp->crop_left >> hshift) << h->pixel_shift ) +
(srcp->crop_top >> vshift) * dst->linesize [i];
||||||| merged common ancestors
for (i = 0 ; i < 3 ; i++) {
int hshift = (i > 0 ) ? h->chroma_x_shift : 0 ;
int vshift = (i > 0 ) ? h->chroma_y_shift : 0 ;
int off = ((h->sps .crop_left >> hshift) << h->pixel_shift ) +
(h->sps .crop_top >> vshift) * dst->linesize [i];
=======
for (i = 0 ; i < 3 ; i++) {
int hshift = (i > 0 ) ? h->chroma_x_shift : 0 ;
int vshift = (i > 0 ) ? h->chroma_y_shift : 0 ;
int off = ((h->ps .sps ->crop_left >> hshift) << h->pixel_shift ) +
(h->ps .sps ->crop_top >> vshift) * dst->linesize [i];
>>>>>>> 3176217c60ca7828712985092d9102d331ea4f3d
dst->data [i] += off;
}
return 0 ;
@@ -1691,6 +1590,9 @@ av_cold void ff_h264_free_context(H264Context *h)
for (i = 0 ; i < MAX_PPS_COUNT; i++)
av_buffer_unref (&h->ps .pps_list [i]);
av_buffer_unref (&h->ps .sps_ref );
av_buffer_unref (&h->ps .pps_ref );
ff_h2645_packet_uninit (&h->pkt );
}