From: softworkz <ffmpegagent@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: softworkz <softworkz@hotmail.com> Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/h264dec: make h264_export_frame_props() accessible Date: Thu, 26 May 2022 08:08:48 +0000 Message-ID: <fb5c3df8e55d55be90631d39d8d7b129cabee33a.1653552529.git.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.31.ffstaging.FFmpeg.1653552529.ffmpegagent@gmail.com> From: softworkz <softworkz@hotmail.com> Signed-off-by: softworkz <softworkz@hotmail.com> --- libavcodec/h264_slice.c | 98 +++++++++++++++++++++-------------------- libavcodec/h264dec.h | 2 + 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index d56722a5c2..f2a4c1c657 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1157,11 +1157,10 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl return 0; } -static int h264_export_frame_props(H264Context *h) +int ff_h264_export_frame_props(AVCodecContext *logctx, H264SEIContext *sei, H264Context *h, AVFrame *out) { - const SPS *sps = h->ps.sps; - H264Picture *cur = h->cur_pic_ptr; - AVFrame *out = cur->f; + const SPS *sps = h ? h->ps.sps : NULL; + H264Picture *cur = h ? h->cur_pic_ptr : NULL; out->interlaced_frame = 0; out->repeat_pict = 0; @@ -1169,19 +1168,19 @@ static int h264_export_frame_props(H264Context *h) /* Signal interlacing information externally. */ /* Prioritize picture timing SEI information over used * decoding process if it exists. */ - if (h->sei.picture_timing.present) { - int ret = ff_h264_sei_process_picture_timing(&h->sei.picture_timing, sps, - h->avctx); + if (sps && sei->picture_timing.present) { + int ret = ff_h264_sei_process_picture_timing(&sei->picture_timing, sps, + logctx); if (ret < 0) { - av_log(h->avctx, AV_LOG_ERROR, "Error processing a picture timing SEI\n"); - if (h->avctx->err_recognition & AV_EF_EXPLODE) + av_log(logctx, AV_LOG_ERROR, "Error processing a picture timing SEI\n"); + if (logctx->err_recognition & AV_EF_EXPLODE) return ret; - h->sei.picture_timing.present = 0; + sei->picture_timing.present = 0; } } - if (sps->pic_struct_present_flag && h->sei.picture_timing.present) { - H264SEIPictureTiming *pt = &h->sei.picture_timing; + if (h && sps && sps->pic_struct_present_flag && sei->picture_timing.present) { + H264SEIPictureTiming *pt = &sei->picture_timing; switch (pt->pic_struct) { case H264_SEI_PIC_STRUCT_FRAME: break; @@ -1215,21 +1214,23 @@ static int h264_export_frame_props(H264Context *h) if ((pt->ct_type & 3) && pt->pic_struct <= H264_SEI_PIC_STRUCT_BOTTOM_TOP) out->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; - } else { + } else if (h) { /* Derive interlacing flag from used decoding process. */ out->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); } - h->prev_interlaced_frame = out->interlaced_frame; - if (cur->field_poc[0] != cur->field_poc[1]) { + if (h) + h->prev_interlaced_frame = out->interlaced_frame; + + if (sps && cur->field_poc[0] != cur->field_poc[1]) { /* Derive top_field_first from field pocs. */ out->top_field_first = cur->field_poc[0] < cur->field_poc[1]; - } else { - if (sps->pic_struct_present_flag && h->sei.picture_timing.present) { + } else if (sps) { + if (sps->pic_struct_present_flag && sei->picture_timing.present) { /* Use picture timing SEI information. Even if it is a * information of a past frame, better than nothing. */ - if (h->sei.picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM || - h->sei.picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP) + if (sei->picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM || + sei->picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP) out->top_field_first = 1; else out->top_field_first = 0; @@ -1243,11 +1244,11 @@ static int h264_export_frame_props(H264Context *h) } } - if (h->sei.frame_packing.present && - h->sei.frame_packing.arrangement_type <= 6 && - h->sei.frame_packing.content_interpretation_type > 0 && - h->sei.frame_packing.content_interpretation_type < 3) { - H264SEIFramePacking *fp = &h->sei.frame_packing; + if (sei->frame_packing.present && + sei->frame_packing.arrangement_type <= 6 && + sei->frame_packing.content_interpretation_type > 0 && + sei->frame_packing.content_interpretation_type < 3) { + H264SEIFramePacking *fp = &sei->frame_packing; AVStereo3D *stereo = av_stereo3d_create_side_data(out); if (stereo) { switch (fp->arrangement_type) { @@ -1289,11 +1290,11 @@ static int h264_export_frame_props(H264Context *h) } } - if (h->sei.display_orientation.present && - (h->sei.display_orientation.anticlockwise_rotation || - h->sei.display_orientation.hflip || - h->sei.display_orientation.vflip)) { - H264SEIDisplayOrientation *o = &h->sei.display_orientation; + if (sei->display_orientation.present && + (sei->display_orientation.anticlockwise_rotation || + sei->display_orientation.hflip || + sei->display_orientation.vflip)) { + H264SEIDisplayOrientation *o = &sei->display_orientation; double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); AVFrameSideData *rotation = av_frame_new_side_data(out, AV_FRAME_DATA_DISPLAYMATRIX, @@ -1314,29 +1315,30 @@ static int h264_export_frame_props(H264Context *h) } } - if (h->sei.afd.present) { + if (sei->afd.present) { AVFrameSideData *sd = av_frame_new_side_data(out, AV_FRAME_DATA_AFD, sizeof(uint8_t)); if (sd) { - *sd->data = h->sei.afd.active_format_description; - h->sei.afd.present = 0; + *sd->data = sei->afd.active_format_description; + sei->afd.present = 0; } } - if (h->sei.a53_caption.buf_ref) { - H264SEIA53Caption *a53 = &h->sei.a53_caption; + if (sei->a53_caption.buf_ref) { + H264SEIA53Caption *a53 = &sei->a53_caption; AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref); if (!sd) av_buffer_unref(&a53->buf_ref); a53->buf_ref = NULL; - h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; + if (h) + h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } - for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) { - H264SEIUnregistered *unreg = &h->sei.unregistered; + for (int i = 0; i < sei->unregistered.nb_buf_ref; i++) { + H264SEIUnregistered *unreg = &sei->unregistered; if (unreg->buf_ref[i]) { AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, @@ -1347,10 +1349,10 @@ static int h264_export_frame_props(H264Context *h) unreg->buf_ref[i] = NULL; } } - h->sei.unregistered.nb_buf_ref = 0; + sei->unregistered.nb_buf_ref = 0; - if (h->sei.film_grain_characteristics.present) { - H264SEIFilmGrainCharacteristics *fgc = &h->sei.film_grain_characteristics; + if (h && sps && sei->film_grain_characteristics.present) { + H264SEIFilmGrainCharacteristics *fgc = &sei->film_grain_characteristics; AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(out); if (!fgp) return AVERROR(ENOMEM); @@ -1404,7 +1406,7 @@ static int h264_export_frame_props(H264Context *h) h->avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; } - if (h->sei.picture_timing.timecode_cnt > 0) { + if (h && sei->picture_timing.timecode_cnt > 0) { uint32_t *tc_sd; char tcbuf[AV_TIMECODE_STR_SIZE]; @@ -1415,14 +1417,14 @@ static int h264_export_frame_props(H264Context *h) return AVERROR(ENOMEM); tc_sd = (uint32_t*)tcside->data; - tc_sd[0] = h->sei.picture_timing.timecode_cnt; + tc_sd[0] = sei->picture_timing.timecode_cnt; for (int i = 0; i < tc_sd[0]; i++) { - int drop = h->sei.picture_timing.timecode[i].dropframe; - int hh = h->sei.picture_timing.timecode[i].hours; - int mm = h->sei.picture_timing.timecode[i].minutes; - int ss = h->sei.picture_timing.timecode[i].seconds; - int ff = h->sei.picture_timing.timecode[i].frame; + int drop = sei->picture_timing.timecode[i].dropframe; + int hh = sei->picture_timing.timecode[i].hours; + int mm = sei->picture_timing.timecode[i].minutes; + int ss = sei->picture_timing.timecode[i].seconds; + int ff = sei->picture_timing.timecode[i].frame; tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff); av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0); @@ -1817,7 +1819,7 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, * field coded frames, since some SEI information is present for each field * and is merged by the SEI parsing code. */ if (!FIELD_PICTURE(h) || !h->first_field || h->missing_fields > 1) { - ret = h264_export_frame_props(h); + ret = ff_h264_export_frame_props(h->avctx, &h->sei, h, h->cur_pic_ptr->f); if (ret < 0) return ret; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 9a1ec1bace..38930da4ca 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -808,4 +808,6 @@ void ff_h264_free_tables(H264Context *h); void ff_h264_set_erpic(ERPicture *dst, H264Picture *src); +int ff_h264_export_frame_props(AVCodecContext *logctx, H264SEIContext *sei, H264Context *h, AVFrame *out); + #endif /* AVCODEC_H264DEC_H */ -- ffmpeg-codebot _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-05-26 8:09 UTC|newest] Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-26 8:08 [FFmpeg-devel] [PATCH 0/6] Implement SEI parsing for QSV decoders ffmpegagent 2022-05-26 8:08 ` [FFmpeg-devel] [PATCH 1/6] avutil/frame: Add av_frame_copy_side_data() and av_frame_remove_all_side_data() softworkz 2022-05-27 14:35 ` Soft Works 2022-05-26 8:08 ` [FFmpeg-devel] [PATCH 2/6] avcodec/vpp_qsv: Copy side data from input to output frame softworkz 2022-05-31 9:19 ` Xiang, Haihao 2022-05-26 8:08 ` [FFmpeg-devel] [PATCH 3/6] avcodec/mpeg12dec: make mpeg_decode_user_data() accessible softworkz 2022-05-31 9:24 ` Xiang, Haihao 2022-05-26 8:08 ` [FFmpeg-devel] [PATCH 4/6] avcodec/hevcdec: make set_side_data() accessible softworkz 2022-05-31 9:38 ` Xiang, Haihao 2022-05-31 16:03 ` Soft Works 2022-05-31 9:40 ` Xiang, Haihao 2022-05-26 8:08 ` softworkz [this message] 2022-05-26 8:08 ` [FFmpeg-devel] [PATCH 6/6] avcodec/qsvdec: Implement SEI parsing for QSV decoders softworkz 2022-06-01 5:15 ` Xiang, Haihao 2022-06-01 8:51 ` Soft Works 2022-06-01 9:06 ` [FFmpeg-devel] [PATCH v2 0/6] " ffmpegagent 2022-06-01 9:06 ` [FFmpeg-devel] [PATCH v2 1/6] avutil/frame: Add av_frame_copy_side_data() and av_frame_remove_all_side_data() softworkz 2022-06-01 9:06 ` [FFmpeg-devel] [PATCH v2 2/6] avcodec/vpp_qsv: Copy side data from input to output frame softworkz 2022-06-01 9:06 ` [FFmpeg-devel] [PATCH v2 3/6] avcodec/mpeg12dec: make mpeg_decode_user_data() accessible softworkz 2022-06-01 9:06 ` [FFmpeg-devel] [PATCH v2 4/6] avcodec/hevcdec: make set_side_data() accessible softworkz 2022-06-01 9:06 ` [FFmpeg-devel] [PATCH v2 5/6] avcodec/h264dec: make h264_export_frame_props() accessible softworkz 2022-06-01 9:06 ` [FFmpeg-devel] [PATCH v2 6/6] avcodec/qsvdec: Implement SEI parsing for QSV decoders softworkz 2022-06-01 17:20 ` Xiang, Haihao 2022-06-01 17:50 ` Soft Works 2022-06-01 18:01 ` [FFmpeg-devel] [PATCH v3 0/6] " ffmpegagent 2022-06-01 18:01 ` [FFmpeg-devel] [PATCH v3 1/6] avutil/frame: Add av_frame_copy_side_data() and av_frame_remove_all_side_data() softworkz 2022-06-24 7:01 ` Xiang, Haihao 2022-06-26 23:35 ` Soft Works 2022-06-01 18:01 ` [FFmpeg-devel] [PATCH v3 2/6] avcodec/vpp_qsv: Copy side data from input to output frame softworkz 2022-06-01 18:01 ` [FFmpeg-devel] [PATCH v3 3/6] avcodec/mpeg12dec: make mpeg_decode_user_data() accessible softworkz 2022-06-01 18:01 ` [FFmpeg-devel] [PATCH v3 4/6] avcodec/hevcdec: make set_side_data() accessible softworkz 2022-06-01 18:01 ` [FFmpeg-devel] [PATCH v3 5/6] avcodec/h264dec: make h264_export_frame_props() accessible softworkz 2022-06-01 18:01 ` [FFmpeg-devel] [PATCH v3 6/6] avcodec/qsvdec: Implement SEI parsing for QSV decoders softworkz 2022-06-26 23:41 ` [FFmpeg-devel] [PATCH v4 0/6] " ffmpegagent 2022-06-26 23:41 ` [FFmpeg-devel] [PATCH v4 1/6] avutil/frame: Add av_frame_copy_side_data() and av_frame_remove_all_side_data() softworkz 2022-06-26 23:41 ` [FFmpeg-devel] [PATCH v4 2/6] avcodec/vpp_qsv: Copy side data from input to output frame softworkz 2022-06-26 23:41 ` [FFmpeg-devel] [PATCH v4 3/6] avcodec/mpeg12dec: make mpeg_decode_user_data() accessible softworkz 2022-06-26 23:41 ` [FFmpeg-devel] [PATCH v4 4/6] avcodec/hevcdec: make set_side_data() accessible softworkz 2022-06-26 23:41 ` [FFmpeg-devel] [PATCH v4 5/6] avcodec/h264dec: make h264_export_frame_props() accessible softworkz 2022-06-26 23:41 ` [FFmpeg-devel] [PATCH v4 6/6] avcodec/qsvdec: Implement SEI parsing for QSV decoders softworkz 2022-06-28 4:16 ` Andreas Rheinhardt 2022-06-28 5:25 ` Soft Works 2022-06-27 4:18 ` [FFmpeg-devel] [PATCH v4 0/6] " Xiang, Haihao 2022-07-01 20:48 ` [FFmpeg-devel] [PATCH v5 " ffmpegagent 2022-07-01 20:48 ` [FFmpeg-devel] [PATCH v5 1/6] avutil/frame: Add av_frame_copy_side_data() and av_frame_remove_all_side_data() softworkz 2022-07-01 20:48 ` [FFmpeg-devel] [PATCH v5 2/6] avcodec/vpp_qsv: Copy side data from input to output frame softworkz 2022-07-01 20:48 ` [FFmpeg-devel] [PATCH v5 3/6] avcodec/mpeg12dec: make mpeg_decode_user_data() accessible softworkz 2022-07-01 20:48 ` [FFmpeg-devel] [PATCH v5 4/6] avcodec/hevcdec: make set_side_data() accessible softworkz 2022-07-01 20:48 ` [FFmpeg-devel] [PATCH v5 5/6] avcodec/h264dec: make h264_export_frame_props() accessible softworkz 2022-07-01 20:48 ` [FFmpeg-devel] [PATCH v5 6/6] avcodec/qsvdec: Implement SEI parsing for QSV decoders softworkz 2022-07-19 6:55 ` [FFmpeg-devel] [PATCH v5 0/6] " Xiang, Haihao 2022-07-21 21:06 ` Soft Works 2022-07-21 21:56 ` Andreas Rheinhardt 2022-10-21 7:42 ` Soft Works 2022-10-25 4:03 ` [FFmpeg-devel] [PATCH v6 0/3] " ffmpegagent 2022-10-25 4:03 ` [FFmpeg-devel] [PATCH v6 1/3] avcodec/hevcdec: factor out ff_hevc_set_set_to_frame softworkz 2022-10-25 4:03 ` [FFmpeg-devel] [PATCH v6 2/3] avcodec/h264dec: make h264_export_frame_props() accessible softworkz 2022-10-25 4:03 ` [FFmpeg-devel] [PATCH v6 3/3] avcodec/qsvdec: Implement SEI parsing for QSV decoders softworkz 2022-11-21 2:44 ` Xiang, Haihao 2022-11-21 15:58 ` Soft Works 2022-11-22 5:41 ` Xiang, Haihao 2022-06-01 19:15 ` [FFmpeg-devel] [PATCH 0/6] " Kieran Kunhya 2022-06-01 19:46 ` Soft Works 2022-06-01 20:25 ` Kieran Kunhya 2022-06-01 21:24 ` Soft Works
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=fb5c3df8e55d55be90631d39d8d7b129cabee33a.1653552529.git.ffmpegagent@gmail.com \ --to=ffmpegagent@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=softworkz@hotmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git