From: softworkz <ffmpegagent@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: softworkz <softworkz@hotmail.com>, "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH v2 4/6] avcodec/hevcdec: make set_side_data() accessible Date: Wed, 01 Jun 2022 09:06:04 +0000 Message-ID: <306bdaa39c04dc97d5b7289cb77c2a4f2b7fb10d.1654074366.git.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.31.v2.ffstaging.FFmpeg.1654074366.ffmpegagent@gmail.com> From: softworkz <softworkz@hotmail.com> Signed-off-by: softworkz <softworkz@hotmail.com> --- libavcodec/hevcdec.c | 117 +++++++++++++++++++++---------------------- libavcodec/hevcdec.h | 9 ++++ 2 files changed, 67 insertions(+), 59 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index f782ea6394..9e9bb48202 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2726,23 +2726,22 @@ error: return res; } -static int set_side_data(HEVCContext *s) +int ff_hevc_set_side_data(AVCodecContext *logctx, HEVCSEI *sei, HEVCContext *s, AVFrame *out) { - AVFrame *out = s->ref->frame; - int ret; + int ret = 0; - if (s->sei.frame_packing.present && - s->sei.frame_packing.arrangement_type >= 3 && - s->sei.frame_packing.arrangement_type <= 5 && - s->sei.frame_packing.content_interpretation_type > 0 && - s->sei.frame_packing.content_interpretation_type < 3) { + if (sei->frame_packing.present && + sei->frame_packing.arrangement_type >= 3 && + sei->frame_packing.arrangement_type <= 5 && + sei->frame_packing.content_interpretation_type > 0 && + sei->frame_packing.content_interpretation_type < 3) { AVStereo3D *stereo = av_stereo3d_create_side_data(out); if (!stereo) return AVERROR(ENOMEM); - switch (s->sei.frame_packing.arrangement_type) { + switch (sei->frame_packing.arrangement_type) { case 3: - if (s->sei.frame_packing.quincunx_subsampling) + if (sei->frame_packing.quincunx_subsampling) stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX; else stereo->type = AV_STEREO3D_SIDEBYSIDE; @@ -2755,21 +2754,21 @@ static int set_side_data(HEVCContext *s) break; } - if (s->sei.frame_packing.content_interpretation_type == 2) + if (sei->frame_packing.content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; - if (s->sei.frame_packing.arrangement_type == 5) { - if (s->sei.frame_packing.current_frame_is_frame0_flag) + if (sei->frame_packing.arrangement_type == 5) { + if (sei->frame_packing.current_frame_is_frame0_flag) stereo->view = AV_STEREO3D_VIEW_LEFT; else stereo->view = AV_STEREO3D_VIEW_RIGHT; } } - if (s->sei.display_orientation.present && - (s->sei.display_orientation.anticlockwise_rotation || - s->sei.display_orientation.hflip || s->sei.display_orientation.vflip)) { - double angle = s->sei.display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16); + if (sei->display_orientation.present && + (sei->display_orientation.anticlockwise_rotation || + sei->display_orientation.hflip || sei->display_orientation.vflip)) { + double angle = sei->display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16); AVFrameSideData *rotation = av_frame_new_side_data(out, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); @@ -2788,17 +2787,17 @@ static int set_side_data(HEVCContext *s) * (1 - 2 * !!s->sei.display_orientation.vflip); av_display_rotation_set((int32_t *)rotation->data, angle); av_display_matrix_flip((int32_t *)rotation->data, - s->sei.display_orientation.hflip, - s->sei.display_orientation.vflip); + sei->display_orientation.hflip, + sei->display_orientation.vflip); } // Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1 // so the side data persists for the entire coded video sequence. - if (s->sei.mastering_display.present > 0 && + if (s && sei->mastering_display.present > 0 && IS_IRAP(s) && s->no_rasl_output_flag) { - s->sei.mastering_display.present--; + sei->mastering_display.present--; } - if (s->sei.mastering_display.present) { + if (sei->mastering_display.present) { // HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b const int mapping[3] = {2, 0, 1}; const int chroma_den = 50000; @@ -2811,25 +2810,25 @@ static int set_side_data(HEVCContext *s) for (i = 0; i < 3; i++) { const int j = mapping[i]; - metadata->display_primaries[i][0].num = s->sei.mastering_display.display_primaries[j][0]; + metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0]; metadata->display_primaries[i][0].den = chroma_den; - metadata->display_primaries[i][1].num = s->sei.mastering_display.display_primaries[j][1]; + metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1]; metadata->display_primaries[i][1].den = chroma_den; } - metadata->white_point[0].num = s->sei.mastering_display.white_point[0]; + metadata->white_point[0].num = sei->mastering_display.white_point[0]; metadata->white_point[0].den = chroma_den; - metadata->white_point[1].num = s->sei.mastering_display.white_point[1]; + metadata->white_point[1].num = sei->mastering_display.white_point[1]; metadata->white_point[1].den = chroma_den; - metadata->max_luminance.num = s->sei.mastering_display.max_luminance; + metadata->max_luminance.num = sei->mastering_display.max_luminance; metadata->max_luminance.den = luma_den; - metadata->min_luminance.num = s->sei.mastering_display.min_luminance; + metadata->min_luminance.num = sei->mastering_display.min_luminance; metadata->min_luminance.den = luma_den; metadata->has_luminance = 1; metadata->has_primaries = 1; - av_log(s->avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); - av_log(s->avctx, AV_LOG_DEBUG, + av_log(logctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); + av_log(logctx, AV_LOG_DEBUG, "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n", av_q2d(metadata->display_primaries[0][0]), av_q2d(metadata->display_primaries[0][1]), @@ -2838,31 +2837,31 @@ static int set_side_data(HEVCContext *s) av_q2d(metadata->display_primaries[2][0]), av_q2d(metadata->display_primaries[2][1]), av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1])); - av_log(s->avctx, AV_LOG_DEBUG, + av_log(logctx, AV_LOG_DEBUG, "min_luminance=%f, max_luminance=%f\n", av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); } // Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1 // so the side data persists for the entire coded video sequence. - if (s->sei.content_light.present > 0 && + if (s && sei->content_light.present > 0 && IS_IRAP(s) && s->no_rasl_output_flag) { - s->sei.content_light.present--; + sei->content_light.present--; } - if (s->sei.content_light.present) { + if (sei->content_light.present) { AVContentLightMetadata *metadata = av_content_light_metadata_create_side_data(out); if (!metadata) return AVERROR(ENOMEM); - metadata->MaxCLL = s->sei.content_light.max_content_light_level; - metadata->MaxFALL = s->sei.content_light.max_pic_average_light_level; + metadata->MaxCLL = sei->content_light.max_content_light_level; + metadata->MaxFALL = sei->content_light.max_pic_average_light_level; - av_log(s->avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n"); - av_log(s->avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n", + av_log(logctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n"); + av_log(logctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n", metadata->MaxCLL, metadata->MaxFALL); } - if (s->sei.a53_caption.buf_ref) { - HEVCSEIA53Caption *a53 = &s->sei.a53_caption; + if (sei->a53_caption.buf_ref) { + HEVCSEIA53Caption *a53 = &sei->a53_caption; AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref); if (!sd) @@ -2870,8 +2869,8 @@ static int set_side_data(HEVCContext *s) a53->buf_ref = NULL; } - for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) { - HEVCSEIUnregistered *unreg = &s->sei.unregistered; + for (int i = 0; i < sei->unregistered.nb_buf_ref; i++) { + HEVCSEIUnregistered *unreg = &sei->unregistered; if (unreg->buf_ref[i]) { AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, @@ -2882,9 +2881,9 @@ static int set_side_data(HEVCContext *s) unreg->buf_ref[i] = NULL; } } - s->sei.unregistered.nb_buf_ref = 0; + sei->unregistered.nb_buf_ref = 0; - if (s->sei.timecode.present) { + if (s && sei->timecode.present) { uint32_t *tc_sd; char tcbuf[AV_TIMECODE_STR_SIZE]; AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE, @@ -2893,25 +2892,25 @@ static int set_side_data(HEVCContext *s) return AVERROR(ENOMEM); tc_sd = (uint32_t*)tcside->data; - tc_sd[0] = s->sei.timecode.num_clock_ts; + tc_sd[0] = sei->timecode.num_clock_ts; for (int i = 0; i < tc_sd[0]; i++) { - int drop = s->sei.timecode.cnt_dropped_flag[i]; - int hh = s->sei.timecode.hours_value[i]; - int mm = s->sei.timecode.minutes_value[i]; - int ss = s->sei.timecode.seconds_value[i]; - int ff = s->sei.timecode.n_frames[i]; + int drop = sei->timecode.cnt_dropped_flag[i]; + int hh = sei->timecode.hours_value[i]; + int mm = sei->timecode.minutes_value[i]; + int ss = sei->timecode.seconds_value[i]; + int ff = sei->timecode.n_frames[i]; tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff); av_timecode_make_smpte_tc_string2(tcbuf, s->avctx->framerate, tc_sd[i + 1], 0, 0); av_dict_set(&out->metadata, "timecode", tcbuf, 0); } - s->sei.timecode.num_clock_ts = 0; + sei->timecode.num_clock_ts = 0; } - if (s->sei.film_grain_characteristics.present) { - HEVCSEIFilmGrainCharacteristics *fgc = &s->sei.film_grain_characteristics; + if (s && sei->film_grain_characteristics.present) { + HEVCSEIFilmGrainCharacteristics *fgc = &sei->film_grain_characteristics; AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(out); if (!fgp) return AVERROR(ENOMEM); @@ -2965,8 +2964,8 @@ static int set_side_data(HEVCContext *s) fgc->present = fgc->persistence_flag; } - if (s->sei.dynamic_hdr_plus.info) { - AVBufferRef *info_ref = av_buffer_ref(s->sei.dynamic_hdr_plus.info); + if (sei->dynamic_hdr_plus.info) { + AVBufferRef *info_ref = av_buffer_ref(sei->dynamic_hdr_plus.info); if (!info_ref) return AVERROR(ENOMEM); @@ -2976,7 +2975,7 @@ static int set_side_data(HEVCContext *s) } } - if (s->rpu_buf) { + if (s && s->rpu_buf) { AVFrameSideData *rpu = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_DOVI_RPU_BUFFER, s->rpu_buf); if (!rpu) return AVERROR(ENOMEM); @@ -2984,10 +2983,10 @@ static int set_side_data(HEVCContext *s) s->rpu_buf = NULL; } - if ((ret = ff_dovi_attach_side_data(&s->dovi_ctx, out)) < 0) + if (s && (ret = ff_dovi_attach_side_data(&s->dovi_ctx, out)) < 0) return ret; - if (s->sei.dynamic_hdr_vivid.info) { + if (s && s->sei.dynamic_hdr_vivid.info) { AVBufferRef *info_ref = av_buffer_ref(s->sei.dynamic_hdr_vivid.info); if (!info_ref) return AVERROR(ENOMEM); @@ -3046,7 +3045,7 @@ static int hevc_frame_start(HEVCContext *s) goto fail; } - ret = set_side_data(s); + ret = ff_hevc_set_side_data(s->avctx, &s->sei, s, s->ref->frame); if (ret < 0) goto fail; diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index de861b88b3..cd8cd40da0 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -690,6 +690,15 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size); +/** + * Set the decodec side data to an AVFrame. + * @logctx context for logging. + * @sei HEVCSEI decoding context, must not be NULL. + * @s HEVCContext, can be NULL. + * @return < 0 on error, 0 otherwise. + */ +int ff_hevc_set_side_data(AVCodecContext *logctx, HEVCSEI *sei, HEVCContext *s, AVFrame *out); + extern const uint8_t ff_hevc_qpel_extra_before[4]; extern const uint8_t ff_hevc_qpel_extra_after[4]; extern const uint8_t ff_hevc_qpel_extra[4]; -- 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-06-01 9:06 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 ` [FFmpeg-devel] [PATCH 5/6] avcodec/h264dec: make h264_export_frame_props() accessible softworkz 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 ` softworkz [this message] 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=306bdaa39c04dc97d5b7289cb77c2a4f2b7fb10d.1654074366.git.ffmpegagent@gmail.com \ --to=ffmpegagent@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=haihao.xiang-at-intel.com@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