From: Devin Heitmueller <devin.heitmueller@ltnglobal.com> To: ffmpeg-devel@ffmpeg.org Cc: Devin Heitmueller <dheitmueller@ltnglobal.com> Subject: [FFmpeg-devel] [RFC][PATCH 1/3] v210enc: Refactor side data passthrough Date: Fri, 21 Jul 2023 17:30:55 -0400 Message-ID: <1689975057-22226-2-git-send-email-dheitmueller@ltnglobal.com> (raw) In-Reply-To: <1689975057-22226-1-git-send-email-dheitmueller@ltnglobal.com> As the number of side-data items we pass through increases, refactor the values into a table in the same manner as done in decode.c. In the future it might make sense to make this a shared function which can be reused by other encoders. But for now keep it local. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> --- libavcodec/v210enc.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index 2a30ed7..110d7eb 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -74,6 +74,13 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, AVFrameSideData *side_data; int ret; uint8_t *dst; + static const struct { + enum AVPacketSideDataType packet; + enum AVFrameSideDataType frame; + } sd[] = { + { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC }, + { AV_PKT_DATA_AFD, AV_FRAME_DATA_AFD }, + }; ret = ff_get_encode_buffer(avctx, pkt, avctx->height * stride, 0); if (ret < 0) { @@ -87,20 +94,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, else if(pic->format == AV_PIX_FMT_YUV422P) v210_enc_8(avctx, dst, pic); - side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_A53_CC); - if (side_data && side_data->size) { - uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, side_data->size); - if (!buf) - return AVERROR(ENOMEM); - memcpy(buf, side_data->data, side_data->size); - } - - side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_AFD); - if (side_data && side_data->size) { - uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_AFD, side_data->size); - if (!buf) - return AVERROR(ENOMEM); - memcpy(buf, side_data->data, side_data->size); + for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) { + side_data = av_frame_get_side_data(pic, sd[i].frame); + if (side_data && side_data->size) { + uint8_t *buf = av_packet_new_side_data(pkt, sd[i].packet, side_data->size); + if (!buf) + return AVERROR(ENOMEM); + memcpy(buf, side_data->data, side_data->size); + } } *got_packet = 1; -- 1.8.3.1 _______________________________________________ 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:[~2023-07-21 21:31 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-21 21:30 [FFmpeg-devel] [RFC][PATCH 0/3] Add support for decklink HDR metadata output Devin Heitmueller 2023-07-21 21:30 ` Devin Heitmueller [this message] 2023-07-21 21:30 ` [FFmpeg-devel] [RFC][PATCH 2/3] v210enc: Add HDR metadata passthrough Devin Heitmueller 2023-07-21 21:30 ` [FFmpeg-devel] [RFC][PATCH 3/3] decklink: Add support for output of HDR metadata Devin Heitmueller
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=1689975057-22226-2-git-send-email-dheitmueller@ltnglobal.com \ --to=devin.heitmueller@ltnglobal.com \ --cc=dheitmueller@ltnglobal.com \ --cc=ffmpeg-devel@ffmpeg.org \ /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