Re: [FFmpeg-devel] [PATCH 1/2] lavfi/dnn_filter_common.h: remove filter option 'options'
> 2021年5月17日 下午1:54,Guo, Yejun 写道: > > we'd use 'backend_configs' to avoid confusion > --- > libavfilter/dnn_filter_common.h | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h > index 09ddd8a5ca..51caa71c24 100644 > --- a/libavfilter/dnn_filter_common.h > +++ b/libavfilter/dnn_filter_common.h > @@ -45,7 +45,6 @@ typedef struct DnnContext { > { "input", "input name of the model", > OFFSET(model_inputname), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS > },\ > { "output", "output name of the model", > OFFSET(model_outputnames_string), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, > FLAGS },\ > { "backend_configs","backend configs", > OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS > },\ > -{ "options","backend configs", > OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS > },\ Not sure if there have users are using this options, What about use deprecated for it? > { "async", "use DNN async inference",OFFSET(async), > AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, FLAGS}, > > > -- > 2.17.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-requ...@ffmpeg.org with subject "unsubscribe". > Thanks Steven Liu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 3/3] avcodec/nvenc: write out user data unregistered SEI
Signed-off-by: Brad Hards --- libavcodec/nvenc.c | 64 ++ 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 0dcd93a99c..e22fdfb5a8 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2170,9 +2170,10 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) NVENCSTATUS nv_status; NvencSurface *tmp_out_surf, *in_surf; int res, res2; -NV_ENC_SEI_PAYLOAD sei_data[8]; +NV_ENC_SEI_PAYLOAD *sei_data = 0; int sei_count = 0; int i; +int total_unregistered_sei = 0; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; @@ -2185,6 +2186,8 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) return AVERROR(EINVAL); if (frame && frame->buf[0]) { +void *a53_data = NULL; +void *tc_data = NULL; in_surf = get_free_frame(ctx); if (!in_surf) return AVERROR(EAGAIN); @@ -2230,7 +2233,6 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) pic_params.inputTimeStamp = frame->pts; if (ctx->a53_cc && av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC)) { -void *a53_data = NULL; size_t a53_size = 0; if (ff_alloc_a53_sei(frame, 0, (void**)&a53_data, &a53_size) < 0) { @@ -2238,15 +2240,21 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } if (a53_data) { -sei_data[sei_count].payloadSize = (uint32_t)a53_size; -sei_data[sei_count].payloadType = 4; -sei_data[sei_count].payload = (uint8_t*)a53_data; -sei_count ++; +sei_data = av_realloc_array(sei_data, sei_count + 1, sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else { +sei_data[sei_count].payloadSize = (uint32_t)a53_size; +sei_data[sei_count].payloadType = 4; +sei_data[sei_count].payload = (uint8_t*)a53_data; +sei_count ++; +} } } if (ctx->s12m_tc && av_frame_get_side_data(frame, AV_FRAME_DATA_S12M_TIMECODE)) { -void *tc_data = NULL; size_t tc_size = 0; if (ff_alloc_timecode_sei(frame, avctx->framerate, 0, (void**)&tc_data, &tc_size) < 0) { @@ -2254,13 +2262,46 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } if (tc_data) { -sei_data[sei_count].payloadSize = (uint32_t)tc_size; -sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; -sei_data[sei_count].payload = (uint8_t*)tc_data; -sei_count ++; +sei_data = av_realloc_array(sei_data, sei_count + 1, sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +av_free(tc_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else { +sei_data[sei_count].payloadSize = (uint32_t)tc_size; +sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; +sei_data[sei_count].payload = (uint8_t*)tc_data; +sei_count ++; +} } } +for (int j = 0; j < frame->nb_side_data; j++) +if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) +total_unregistered_sei++; +if (total_unregistered_sei > 0) { +sei_data = av_realloc_array(sei_data, +sei_count + total_unregistered_sei, +sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +av_free(tc_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else +for (int j = 0; j < frame->nb_side_data; j++) { +AVFrameSideData *side_data = frame->side_data[j]; +if (side_data->type == AV_FRAME_DATA_SEI_UNREGISTERED) { +sei_data[sei_count].payloadSize = side_data->size; +sei_data[sei_count].payloadType = SEI_TYPE_USER_DATA_UNREGISTERED; +sei_data[sei_count].payload = av_memdup(side_data->data, side_data->size); +if (sei_data[sei_count].payload) +sei_count ++; +} +} +} + nvenc_codec_specific_pic_params(avctx, &pic_params, sei_data, sei_count); } el
[FFmpeg-devel] [PATCH v4 2/3] libavcodec/libx265: write out user data unregistered SEI
Signed-off-by: Brad Hards --- libavcodec/libx265.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index a1bd205201..d66506dda9 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -484,6 +484,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int nnal; int ret; int i; +int total_unregistered_sei; ctx->api->picture_init(ctx->params, &x265pic); @@ -515,6 +516,27 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, memcpy(x265pic.userData, &pic->reordered_opaque, sizeof(pic->reordered_opaque)); } +for (int j = 0; j < pic->nb_side_data; j++) +if (pic->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) +total_unregistered_sei++; +if (total_unregistered_sei > 0) { +x265_sei *sei = &(x265pic.userSEI); +sei->payloads = av_realloc_array(sei->payloads, + sei->numPayloads + total_unregistered_sei, + sizeof(x265_sei_payload)); +if (!sei->payloads) { +sei->numPayloads = 0; +return AVERROR(ENOMEM); +} else +for (int j = 0; j < pic->nb_side_data; j++) +if (pic->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) { +x265_sei_payload *payload = &(sei->payloads[sei->numPayloads]); +payload->payload = pic->side_data[j]->data; +payload->payloadSize = pic->side_data[j]->size; +payload->payloadType = USER_DATA_UNREGISTERED; +sei->numPayloads++; +} +} } ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] (no subject)
MISB ST 0604 and ST 2101 require user data unregistered SEI messages (precision timestamps and sensor identifiers) to be included. That currently isn't supported. This series adds encoding for libx264, libx265, hevc_nvenc and h264_nvenc in accordance with ISO/IEC 14496-10:2020 Section D.1.7 and ISO/IEC 23008-2:2020 Section D.2.7. v2 removed the API addition, modifies nvenc to use a dynamic array, and corrects formatting. v3 removes the example, and improves memory allocation handling. v4 returns ENOMEM instead of continuing in the event of allocation failure, and updates the commit messages (consistent with majority usage for the affected codec). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 1/3] libavcodec/libx264: write out user data unregistered SEI
Signed-off-by: Brad Hards --- libavcodec/libx264.c | 35 ++- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 1c27f7b441..1fac141ec6 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -31,6 +31,7 @@ #include "internal.h" #include "packet_internal.h" #include "atsc_a53.h" +#include "sei.h" #if defined(_MSC_VER) #define X264_API_IMPORTS 1 @@ -303,6 +304,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int64_t wallclock = 0; X264Opaque *out_opaque; AVFrameSideData *sd; +int total_unreg_sei = 0; x264_picture_init( &x4->pic ); x4->pic.img.i_csp = x4->params.i_csp; @@ -316,6 +318,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); if (frame) { +void *sei_data_a53_cc; for (i = 0; i < x4->pic.img.i_plane; i++) { x4->pic.img.plane[i]= frame->data[i]; x4->pic.img.i_stride[i] = frame->linesize[i]; @@ -349,28 +352,50 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, reconfig_encoder(ctx, frame); if (x4->a53_cc) { -void *sei_data; size_t sei_size; -ret = ff_alloc_a53_sei(frame, 0, &sei_data, &sei_size); +ret = ff_alloc_a53_sei(frame, 0, &sei_data_a53_cc, &sei_size); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n"); -} else if (sei_data) { +} else if (sei_data_a53_cc) { x4->pic.extra_sei.payloads = av_mallocz(sizeof(x4->pic.extra_sei.payloads[0])); if (x4->pic.extra_sei.payloads == NULL) { av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n"); -av_free(sei_data); +av_free(sei_data_a53_cc); } else { x4->pic.extra_sei.sei_free = av_free; x4->pic.extra_sei.payloads[0].payload_size = sei_size; -x4->pic.extra_sei.payloads[0].payload = sei_data; +x4->pic.extra_sei.payloads[0].payload = sei_data_a53_cc; x4->pic.extra_sei.num_payloads = 1; x4->pic.extra_sei.payloads[0].payload_type = 4; } } } +for (int j = 0; j < frame->nb_side_data; j++) +if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) +total_unreg_sei++; +if (total_unreg_sei > 0) { +x264_sei_t *sei = &(x4->pic.extra_sei); +sei->payloads = av_realloc_array(sei->payloads, + sei->num_payloads + total_unreg_sei, + sizeof(x264_sei_payload_t)); +if (!sei->payloads) { +av_free(sei_data_a53_cc); +sei->num_payloads = 0; +return AVERROR(ENOMEM); +} else +for (int j = 0; j < frame->nb_side_data; j++) +if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) { +x264_sei_payload_t *payload = &(sei->payloads[sei->num_payloads]); +payload->payload = frame->side_data[j]->data; +payload->payload_size = frame->side_data[j]->size; +payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED; +sei->num_payloads++; +} +} + sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST); if (sd) { if (x4->params.rc.i_aq_mode == X264_AQ_NONE) { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] lavfi/dnn_filter_common.h: remove filter option 'options'
> -Original Message- > From: Steven Liu > Sent: 2021年5月17日 15:46 > To: FFmpeg development discussions and patches > > Cc: Steven Liu ; Guo, Yejun > Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavfi/dnn_filter_common.h: remove > filter option 'options' > > > > > 2021年5月17日 下午1:54,Guo, Yejun 写道: > > > > we'd use 'backend_configs' to avoid confusion > > --- > > libavfilter/dnn_filter_common.h | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/libavfilter/dnn_filter_common.h > b/libavfilter/dnn_filter_common.h > > index 09ddd8a5ca..51caa71c24 100644 > > --- a/libavfilter/dnn_filter_common.h > > +++ b/libavfilter/dnn_filter_common.h > > @@ -45,7 +45,6 @@ typedef struct DnnContext { > > { "input", "input name of the model", > OFFSET(model_inputname), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, > FLAGS },\ > > { "output", "output name of the model", > OFFSET(model_outputnames_string), AV_OPT_TYPE_STRING, { .str = NULL }, 0, > 0, FLAGS },\ > > { "backend_configs","backend configs", > OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, > FLAGS },\ > > -{ "options","backend configs", > OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, > FLAGS },\ > Not sure if there have users are using this options, > What about use deprecated for it? yes, will add AV_OPT_FLAG_DEPRECATED into FLAGS, thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] Encode user data unregistered SEI (H.264/H.265)
MISB ST 0604 and ST 2101 require user data unregistered SEI messages (precision timestamps and sensor identifiers) to be included. That currently isn't supported. This series adds encoding for libx264, libx265, hevc_nvenc and h264_nvenc in accordance with ISO/IEC 14496-10:2020 Section D.1.7 and ISO/IEC 23008-2:2020 Section D.2.7. v2 removed the API addition, modifies nvenc to use a dynamic array, and corrects formatting. v3 removes the example, and improves memory allocation handling. v4 returns ENOMEM instead of continuing in the event of allocation failure, and updates the commit messages (consistent with majority usage for the affected codec). v5 fixes the covering email subject. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 1/3] libavcodec/libx264: write out user data unregistered SEI
Signed-off-by: Brad Hards --- libavcodec/libx264.c | 35 ++- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 1c27f7b441..1fac141ec6 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -31,6 +31,7 @@ #include "internal.h" #include "packet_internal.h" #include "atsc_a53.h" +#include "sei.h" #if defined(_MSC_VER) #define X264_API_IMPORTS 1 @@ -303,6 +304,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int64_t wallclock = 0; X264Opaque *out_opaque; AVFrameSideData *sd; +int total_unreg_sei = 0; x264_picture_init( &x4->pic ); x4->pic.img.i_csp = x4->params.i_csp; @@ -316,6 +318,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); if (frame) { +void *sei_data_a53_cc; for (i = 0; i < x4->pic.img.i_plane; i++) { x4->pic.img.plane[i]= frame->data[i]; x4->pic.img.i_stride[i] = frame->linesize[i]; @@ -349,28 +352,50 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, reconfig_encoder(ctx, frame); if (x4->a53_cc) { -void *sei_data; size_t sei_size; -ret = ff_alloc_a53_sei(frame, 0, &sei_data, &sei_size); +ret = ff_alloc_a53_sei(frame, 0, &sei_data_a53_cc, &sei_size); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n"); -} else if (sei_data) { +} else if (sei_data_a53_cc) { x4->pic.extra_sei.payloads = av_mallocz(sizeof(x4->pic.extra_sei.payloads[0])); if (x4->pic.extra_sei.payloads == NULL) { av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n"); -av_free(sei_data); +av_free(sei_data_a53_cc); } else { x4->pic.extra_sei.sei_free = av_free; x4->pic.extra_sei.payloads[0].payload_size = sei_size; -x4->pic.extra_sei.payloads[0].payload = sei_data; +x4->pic.extra_sei.payloads[0].payload = sei_data_a53_cc; x4->pic.extra_sei.num_payloads = 1; x4->pic.extra_sei.payloads[0].payload_type = 4; } } } +for (int j = 0; j < frame->nb_side_data; j++) +if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) +total_unreg_sei++; +if (total_unreg_sei > 0) { +x264_sei_t *sei = &(x4->pic.extra_sei); +sei->payloads = av_realloc_array(sei->payloads, + sei->num_payloads + total_unreg_sei, + sizeof(x264_sei_payload_t)); +if (!sei->payloads) { +av_free(sei_data_a53_cc); +sei->num_payloads = 0; +return AVERROR(ENOMEM); +} else +for (int j = 0; j < frame->nb_side_data; j++) +if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) { +x264_sei_payload_t *payload = &(sei->payloads[sei->num_payloads]); +payload->payload = frame->side_data[j]->data; +payload->payload_size = frame->side_data[j]->size; +payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED; +sei->num_payloads++; +} +} + sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST); if (sd) { if (x4->params.rc.i_aq_mode == X264_AQ_NONE) { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 2/3] libavcodec/libx265: write out user data unregistered SEI
Signed-off-by: Brad Hards --- libavcodec/libx265.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index a1bd205201..d66506dda9 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -484,6 +484,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int nnal; int ret; int i; +int total_unregistered_sei; ctx->api->picture_init(ctx->params, &x265pic); @@ -515,6 +516,27 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, memcpy(x265pic.userData, &pic->reordered_opaque, sizeof(pic->reordered_opaque)); } +for (int j = 0; j < pic->nb_side_data; j++) +if (pic->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) +total_unregistered_sei++; +if (total_unregistered_sei > 0) { +x265_sei *sei = &(x265pic.userSEI); +sei->payloads = av_realloc_array(sei->payloads, + sei->numPayloads + total_unregistered_sei, + sizeof(x265_sei_payload)); +if (!sei->payloads) { +sei->numPayloads = 0; +return AVERROR(ENOMEM); +} else +for (int j = 0; j < pic->nb_side_data; j++) +if (pic->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) { +x265_sei_payload *payload = &(sei->payloads[sei->numPayloads]); +payload->payload = pic->side_data[j]->data; +payload->payloadSize = pic->side_data[j]->size; +payload->payloadType = USER_DATA_UNREGISTERED; +sei->numPayloads++; +} +} } ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 3/3] avcodec/nvenc: write out user data unregistered SEI
Signed-off-by: Brad Hards --- libavcodec/nvenc.c | 64 ++ 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 0dcd93a99c..e22fdfb5a8 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2170,9 +2170,10 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) NVENCSTATUS nv_status; NvencSurface *tmp_out_surf, *in_surf; int res, res2; -NV_ENC_SEI_PAYLOAD sei_data[8]; +NV_ENC_SEI_PAYLOAD *sei_data = 0; int sei_count = 0; int i; +int total_unregistered_sei = 0; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; @@ -2185,6 +2186,8 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) return AVERROR(EINVAL); if (frame && frame->buf[0]) { +void *a53_data = NULL; +void *tc_data = NULL; in_surf = get_free_frame(ctx); if (!in_surf) return AVERROR(EAGAIN); @@ -2230,7 +2233,6 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) pic_params.inputTimeStamp = frame->pts; if (ctx->a53_cc && av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC)) { -void *a53_data = NULL; size_t a53_size = 0; if (ff_alloc_a53_sei(frame, 0, (void**)&a53_data, &a53_size) < 0) { @@ -2238,15 +2240,21 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } if (a53_data) { -sei_data[sei_count].payloadSize = (uint32_t)a53_size; -sei_data[sei_count].payloadType = 4; -sei_data[sei_count].payload = (uint8_t*)a53_data; -sei_count ++; +sei_data = av_realloc_array(sei_data, sei_count + 1, sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else { +sei_data[sei_count].payloadSize = (uint32_t)a53_size; +sei_data[sei_count].payloadType = 4; +sei_data[sei_count].payload = (uint8_t*)a53_data; +sei_count ++; +} } } if (ctx->s12m_tc && av_frame_get_side_data(frame, AV_FRAME_DATA_S12M_TIMECODE)) { -void *tc_data = NULL; size_t tc_size = 0; if (ff_alloc_timecode_sei(frame, avctx->framerate, 0, (void**)&tc_data, &tc_size) < 0) { @@ -2254,13 +2262,46 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } if (tc_data) { -sei_data[sei_count].payloadSize = (uint32_t)tc_size; -sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; -sei_data[sei_count].payload = (uint8_t*)tc_data; -sei_count ++; +sei_data = av_realloc_array(sei_data, sei_count + 1, sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +av_free(tc_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else { +sei_data[sei_count].payloadSize = (uint32_t)tc_size; +sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; +sei_data[sei_count].payload = (uint8_t*)tc_data; +sei_count ++; +} } } +for (int j = 0; j < frame->nb_side_data; j++) +if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) +total_unregistered_sei++; +if (total_unregistered_sei > 0) { +sei_data = av_realloc_array(sei_data, +sei_count + total_unregistered_sei, +sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +av_free(tc_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else +for (int j = 0; j < frame->nb_side_data; j++) { +AVFrameSideData *side_data = frame->side_data[j]; +if (side_data->type == AV_FRAME_DATA_SEI_UNREGISTERED) { +sei_data[sei_count].payloadSize = side_data->size; +sei_data[sei_count].payloadType = SEI_TYPE_USER_DATA_UNREGISTERED; +sei_data[sei_count].payload = av_memdup(side_data->data, side_data->size); +if (sei_data[sei_count].payload) +sei_count ++; +} +} +} + nvenc_codec_specific_pic_params(avctx, &pic_params, sei_data, sei_count); } el
Re: [FFmpeg-devel] [PATCH v1] avcodec/vaapi_av1: correct data size when create slice data buffer
On 17.05.21 03:50, Fei Wang wrote: > Set all tiles size to create slice data buffer, hardware will use > slice_data_offset/slice_data_size in slice parameter buffer to get > each tile's data. > > This change will let it success to decode clip which has multi > tiles data inside one OBU. > > Signed-off-by: Fei Wang > --- > libavcodec/vaapi_av1.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c > index 1809b485aa..16b7e35747 100644 > --- a/libavcodec/vaapi_av1.c > +++ b/libavcodec/vaapi_av1.c > @@ -292,7 +292,7 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx, > err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, > > sizeof(VASliceParameterBufferAV1), > buffer, > - > s->tile_group_info[i].tile_size); > +size); > if (err) { > ff_vaapi_decode_cancel(avctx, pic); > return err; +1, I can confirm that this fix works using mpv/kodi. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH V2] lavfi/dnn_filter_common.h: make filter option 'options' as deprecated
we'd use 'backend_configs' to avoid confusion. --- libavfilter/dnn_filter_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h index 09ddd8a5ca..36319bfef8 100644 --- a/libavfilter/dnn_filter_common.h +++ b/libavfilter/dnn_filter_common.h @@ -45,7 +45,7 @@ typedef struct DnnContext { { "input", "input name of the model", OFFSET(model_inputname), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },\ { "output", "output name of the model", OFFSET(model_outputnames_string), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },\ { "backend_configs","backend configs", OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },\ -{ "options","backend configs", OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },\ +{ "options", "backend configs (deprecated, use backend_configs)", OFFSET(backend_options), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS | AV_OPT_FLAG_DEPRECATED},\ { "async", "use DNN async inference",OFFSET(async), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, FLAGS}, -- 2.17.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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1] avcodec/vaapi_av1: correct data size when create slice data buffer
On Mon, May 17, 2021 at 4:50 AM Fei Wang wrote: > > Set all tiles size to create slice data buffer, hardware will use > slice_data_offset/slice_data_size in slice parameter buffer to get > each tile's data. > > This change will let it success to decode clip which has multi > tiles data inside one OBU. > > Signed-off-by: Fei Wang > --- > libavcodec/vaapi_av1.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c > index 1809b485aa..16b7e35747 100644 > --- a/libavcodec/vaapi_av1.c > +++ b/libavcodec/vaapi_av1.c > @@ -292,7 +292,7 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx, > err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, > > sizeof(VASliceParameterBufferAV1), > buffer, > - > s->tile_group_info[i].tile_size); > +size); > if (err) { > ff_vaapi_decode_cancel(avctx, pic); > return err; > -- > 2.17.1 So basically this fixes setting the size of the passed buffer to the whole size of the buffer (in which tile offset and tile size should always be located). As such it makes sense. It seems like at some point there was an idea to only pass "buffer + tile_offset", but that never materialized completely (and then setting VASliceParameterBufferAV1's tile_offset to 0)? Would that lead to smaller buffers being utilized? Or does libva already extract the tiles into their own buffers based on the information? Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] Add nit flag support
Signed-off-by: Ubaldo Porcheddu --- doc/muxers.texi | 2 ++ libavformat/mpegtsenc.c | 96 ++--- 2 files changed, 93 insertions(+), 5 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index e1c6ad0829..f774d972a6 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1876,6 +1876,8 @@ Reemit PAT and PMT at each video frame. Conform to System B (DVB) instead of System A (ATSC). @item initial_discontinuity Mark the initial packet of each stream as discontinuity. +@item nit +Emit NIT table. @end table @item mpegts_copyts @var{boolean} diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index e3f9d9ad50..68abccf9ca 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -76,10 +76,12 @@ typedef struct MpegTSWrite { const AVClass *av_class; MpegTSSection pat; /* MPEG-2 PAT table */ MpegTSSection sdt; /* MPEG-2 SDT table context */ +MpegTSSection nit; /* MPEG-2 NIT table context */ MpegTSService **services; AVPacket *pkt; int64_t sdt_period; /* SDT period in PCR time base */ int64_t pat_period; /* PAT/PMT period in PCR time base */ +int64_t nit_period; /* NIT period in PCR time base */ int nb_services; int64_t first_pcr; int first_dts_checked; @@ -107,13 +109,18 @@ typedef struct MpegTSWrite { #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES 0x04 #define MPEGTS_FLAG_SYSTEM_B0x08 #define MPEGTS_FLAG_DISCONT 0x10 +#define MPEGTS_FLAG_NIT 0x20 int flags; int copyts; int tables_version; int64_t pat_period_us; int64_t sdt_period_us; +int64_t nit_period_us; int64_t last_pat_ts; int64_t last_sdt_ts; +int64_t last_nit_ts; + +uint8_t provider_name[256]; int omit_video_pes_length; } MpegTSWrite; @@ -227,6 +234,7 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, int id, #define SDT_RETRANS_TIME 500 #define PAT_RETRANS_TIME 100 #define PCR_RETRANS_TIME 20 +#define NIT_RETRANS_TIME 500 typedef struct MpegTSWriteStream { int pid; /* stream associated pid */ @@ -796,6 +804,47 @@ static void mpegts_write_sdt(AVFormatContext *s) data, q - data); } +static void mpegts_write_nit(AVFormatContext *s) +{ +int i; +MpegTSWrite *ts = s->priv_data; +uint8_t data[SECTION_LENGTH], *q, *desc_len_ptr, *loop_len_ptr; +AVProgram *program; + +q = data; + +//network name +put16(&q, 0xf000 | ts->provider_name[0]); +*q++ = 0x40; +putbuf(&q, ts->provider_name, ts->provider_name[0]+1); + +//TS loop +loop_len_ptr = q; +q += 2; +put16(&q, ts->transport_stream_id); +put16(&q, ts->original_network_id); + +//transport descriptor +desc_len_ptr = q; +q += 2; + +//service list descriptor +*q++ = 0x41; +*q++ = 3 * ts->nb_services; +for(i = 0; i < ts->nb_services; i++) { +put16(&q, ts->services[i]->sid); +*q++ = ts->service_type; +program = s->programs[i]; +} + +//calculate lengths +put16(&desc_len_ptr, 0xf000 | q - (desc_len_ptr+2)); +put16(&loop_len_ptr, 0xf000 | q - (loop_len_ptr+2)); + +mpegts_write_section1(&ts->nit, NIT_TID, ts->original_network_id, ts->tables_version, 0, 0, + data, q - data); +} + /* This stores a string in buf with the correct encoding and also sets the * first byte as the length. !str is accepted for an empty string. * If the string is already encoded, invalid UTF-8 or has no multibyte sequence @@ -966,6 +1015,8 @@ static void select_pcr_streams(AVFormatContext *s) static int mpegts_init(AVFormatContext *s) { MpegTSWrite *ts = s->priv_data; +AVDictionaryEntry *provider; +const char *provider_name; int i, j; int ret; @@ -1022,6 +1073,12 @@ static int mpegts_init(AVFormatContext *s) ts->sdt.write_packet = section_write_packet; ts->sdt.opaque = s; +ts->nit.pid = NIT_PID; +ts->nit.cc = 15; +ts->nit.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT; +ts->nit.write_packet = section_write_packet; +ts->nit.opaque = s; + ts->pkt = av_packet_alloc(); if (!ts->pkt) return AVERROR(ENOMEM); @@ -1143,23 +1200,36 @@ static int mpegts_init(AVFormatContext *s) ts->last_pat_ts = AV_NOPTS_VALUE; ts->last_sdt_ts = AV_NOPTS_VALUE; +ts->last_nit_ts = AV_NOPTS_VALUE; ts->pat_period = av_rescale(ts->pat_period_us, PCR_TIME_BASE, AV_TIME_BASE); ts->sdt_period = av_rescale(ts->sdt_period_us, PCR_TIME_BASE, AV_TIME_BASE); +ts->nit_period = av_rescale(ts->nit_period_us, PCR_TIME_BASE, AV_TIME_BASE); + +/* assign provider name */ +provider = av_dict_get(s->metadata, "service_provider", NULL, 0); +provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME; +if (encode_str8(ts->provider_name, provider_name) < 0)
[FFmpeg-devel] [PATCH] aarch64: hevc_idct: Fix overflows in idct_dc
This is marginally slower, but correct for all input values. The previous implementation failed with certain input seeds, e.g. "checkasm --test=hevc_idct 98". --- libavcodec/aarch64/hevcdsp_idct_neon.S | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S b/libavcodec/aarch64/hevcdsp_idct_neon.S index 28c11e632c..0869431294 100644 --- a/libavcodec/aarch64/hevcdsp_idct_neon.S +++ b/libavcodec/aarch64/hevcdsp_idct_neon.S @@ -573,14 +573,13 @@ idct_16x16 10 // void ff_hevc_idct_NxN_dc_DEPTH_neon(int16_t *coeffs) .macro idct_dc size, bitdepth function ff_hevc_idct_\size\()x\size\()_dc_\bitdepth\()_neon, export=1 -movi v1.8h, #((1 << (14 - \bitdepth))+1) ld1r {v4.8h}, [x0] -add v4.8h, v4.8h, v1.8h -sshr v0.8h, v4.8h, #(15 - \bitdepth) -sshr v1.8h, v4.8h, #(15 - \bitdepth) +srshr v4.8h, v4.8h, #1 +srshr v0.8h, v4.8h, #(14 - \bitdepth) +srshr v1.8h, v4.8h, #(14 - \bitdepth) .if \size > 4 -sshr v2.8h, v4.8h, #(15 - \bitdepth) -sshr v3.8h, v4.8h, #(15 - \bitdepth) +srshr v2.8h, v4.8h, #(14 - \bitdepth) +srshr v3.8h, v4.8h, #(14 - \bitdepth) .if \size > 16 /* dc 32x32 */ mov x2, #4 1: -- 2.25.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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 3/3] avcodec/nvenc: write out user data unregistered SEI
On 17.05.2021 10:19, Brad Hards wrote: Signed-off-by: Brad Hards --- libavcodec/nvenc.c | 64 ++ 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 0dcd93a99c..e22fdfb5a8 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2170,9 +2170,10 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) NVENCSTATUS nv_status; NvencSurface *tmp_out_surf, *in_surf; int res, res2; -NV_ENC_SEI_PAYLOAD sei_data[8]; +NV_ENC_SEI_PAYLOAD *sei_data = 0; int sei_count = 0; int i; +int total_unregistered_sei = 0; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; @@ -2185,6 +2186,8 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) return AVERROR(EINVAL); if (frame && frame->buf[0]) { +void *a53_data = NULL; +void *tc_data = NULL; in_surf = get_free_frame(ctx); if (!in_surf) return AVERROR(EAGAIN); @@ -2230,7 +2233,6 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) pic_params.inputTimeStamp = frame->pts; if (ctx->a53_cc && av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC)) { -void *a53_data = NULL; size_t a53_size = 0; if (ff_alloc_a53_sei(frame, 0, (void**)&a53_data, &a53_size) < 0) { @@ -2238,15 +2240,21 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } if (a53_data) { -sei_data[sei_count].payloadSize = (uint32_t)a53_size; -sei_data[sei_count].payloadType = 4; -sei_data[sei_count].payload = (uint8_t*)a53_data; -sei_count ++; +sei_data = av_realloc_array(sei_data, sei_count + 1, sizeof(NV_ENC_SEI_PAYLOAD)); Doing this realloc dance every frame is extremely inefficient. The sei_data array and its current size could instead be stored in the nvenc context, with a best-guess initial size, and then only grow when the already allocated size is too small. +if (!sei_data) { +av_free(a53_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else { +sei_data[sei_count].payloadSize = (uint32_t)a53_size; +sei_data[sei_count].payloadType = 4; +sei_data[sei_count].payload = (uint8_t*)a53_data; +sei_count ++; +} } } if (ctx->s12m_tc && av_frame_get_side_data(frame, AV_FRAME_DATA_S12M_TIMECODE)) { -void *tc_data = NULL; size_t tc_size = 0; if (ff_alloc_timecode_sei(frame, avctx->framerate, 0, (void**)&tc_data, &tc_size) < 0) { @@ -2254,13 +2262,46 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } if (tc_data) { -sei_data[sei_count].payloadSize = (uint32_t)tc_size; -sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; -sei_data[sei_count].payload = (uint8_t*)tc_data; -sei_count ++; +sei_data = av_realloc_array(sei_data, sei_count + 1, sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +av_free(tc_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else { +sei_data[sei_count].payloadSize = (uint32_t)tc_size; +sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; +sei_data[sei_count].payload = (uint8_t*)tc_data; +sei_count ++; +} } } +for (int j = 0; j < frame->nb_side_data; j++) +if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) +total_unregistered_sei++; +if (total_unregistered_sei > 0) { +sei_data = av_realloc_array(sei_data, +sei_count + total_unregistered_sei, +sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { +av_free(a53_data); +av_free(tc_data); +sei_count = 0; +return AVERROR(ENOMEM); +} else +for (int j = 0; j < frame->nb_side_data; j++) { +AVFrameSideData *side_data = frame->side_data[j]; +if (side_data->type == AV_FRAME_DATA_SEI_UNREGISTERED) { +sei_data[sei_count].payloadSize = side_data->size; +sei_data[sei_count].payloadType = SEI_TYPE_USER_DATA_UNREGISTERED; +
Re: [FFmpeg-devel] [PATCH v5 3/3] avcodec/nvenc: write out user data unregistered SEI
On Mon, 17 May 2021, Timo Rothenpieler wrote: On 17.05.2021 10:19, Brad Hards wrote: Signed-off-by: Brad Hards --- libavcodec/nvenc.c | 64 ++ 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 0dcd93a99c..e22fdfb5a8 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -2170,9 +2170,10 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) NVENCSTATUS nv_status; NvencSurface *tmp_out_surf, *in_surf; int res, res2; -NV_ENC_SEI_PAYLOAD sei_data[8]; +NV_ENC_SEI_PAYLOAD *sei_data = 0; int sei_count = 0; int i; +int total_unregistered_sei = 0; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; @@ -2185,6 +2186,8 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) return AVERROR(EINVAL); if (frame && frame->buf[0]) { +void *a53_data = NULL; +void *tc_data = NULL; in_surf = get_free_frame(ctx); if (!in_surf) return AVERROR(EAGAIN); @@ -2230,7 +2233,6 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) pic_params.inputTimeStamp = frame->pts; if (ctx->a53_cc && av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC)) { -void *a53_data = NULL; size_t a53_size = 0; if (ff_alloc_a53_sei(frame, 0, (void**)&a53_data, &a53_size) < 0) { @@ -2238,15 +2240,21 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } if (a53_data) { -sei_data[sei_count].payloadSize = (uint32_t)a53_size; -sei_data[sei_count].payloadType = 4; -sei_data[sei_count].payload = (uint8_t*)a53_data; -sei_count ++; +sei_data = av_realloc_array(sei_data, sei_count + 1, sizeof(NV_ENC_SEI_PAYLOAD)); Doing this realloc dance every frame is extremely inefficient. The sei_data array and its current size could instead be stored in the nvenc context, with a best-guess initial size, and then only grow when the already allocated size is too small. Don't we have av_fast_realloc for this? Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 3/3] avcodec/nvenc: write out user data unregistered SEI
On 17.05.2021 17:52, Marton Balint wrote: Don't we have av_fast_realloc for this? Yes, but you still need to save the pointer for that somewhere. smime.p7s Description: S/MIME Cryptographic Signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCHv5] fate/integer.c: Connect test to fuzzer
Hi, I have removed the tests for overflow & reduced the number of bits read to 32-bit to avoid overflow. Best regards --- Makefile | 2 ++ libavutil/tests/integer.c | 21 ++ libavutil/tests/integer.h | 45 +++ tools/Makefile| 3 +++ tools/target_int_fuzzer.c | 35 ++ 5 files changed, 87 insertions(+), 19 deletions(-) create mode 100644 libavutil/tests/integer.h create mode 100644 tools/target_int_fuzzer.c diff --git a/Makefile b/Makefile index 7e9d8b08c3..92fe8cac65 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,8 @@ tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS) tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS) $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) +tools/target_int_fuzzer$(EXESUF): tools/target_int_fuzzer.o $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS) tools/enum_options$(EXESUF): $(FF_DEP_LIBS) diff --git a/libavutil/tests/integer.c b/libavutil/tests/integer.c index d2c8f2a903..02e1d9219c 100644 --- a/libavutil/tests/integer.c +++ b/libavutil/tests/integer.c @@ -18,31 +18,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - -#include "libavutil/avassert.h" -#include "libavutil/integer.h" -#include "libavutil/intmath.h" +#include "libavutil/tests/integer.h" int main(void){ int64_t a,b; for(a=7; a<256*256*256; a+=13215){ for(b=3; b<256*256*256; b+=27118){ -AVInteger ai= av_int2i(a); -AVInteger bi= av_int2i(b); - -av_assert0(av_i2int(ai) == a); -av_assert0(av_i2int(bi) == b); -av_assert0(av_i2int(av_add_i(ai,bi)) == a+b); -av_assert0(av_i2int(av_sub_i(ai,bi)) == a-b); -av_assert0(av_i2int(av_mul_i(ai,bi)) == a*b); -av_assert0(av_i2int(av_shr_i(ai, 9)) == a>>9); -av_assert0(av_i2int(av_shr_i(ai,-9)) == a<<9); -av_assert0(av_i2int(av_shr_i(ai, 17)) == a>>17); -av_assert0(av_i2int(av_shr_i(ai,-17)) == a<<17); -av_assert0(av_log2_i(ai) == av_log2(a)); -av_assert0(av_i2int(av_div_i(ai,bi)) == a/b); +TestInteger(a,b); } } return 0; diff --git a/libavutil/tests/integer.h b/libavutil/tests/integer.h new file mode 100644 index 00..1e28c29787 --- /dev/null +++ b/libavutil/tests/integer.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef AVUTIL_TESTS_INTEGER_H +#define AVUTIL_TESTS_INTEGER_H + +#include +#include "libavutil/avassert.h" +#include "libavutil/integer.h" +#include "libavutil/intmath.h" + +static inline void TestInteger(int64_t a, int64_t b) +{ +AVInteger ai= av_int2i(a); +AVInteger bi= av_int2i(b); + +av_assert0(av_i2int(ai) == a); +av_assert0(av_i2int(bi) == b); +av_assert0(av_i2int(av_add_i(ai,bi)) == a+b); +av_assert0(av_i2int(av_sub_i(ai,bi)) == a-b); +av_assert0(av_i2int(av_mul_i(ai,bi)) == a*b); +av_assert0(av_i2int(av_shr_i(ai, 9)) == a>>9); +av_assert0(av_i2int(av_shr_i(ai,-9)) == a<<9); +av_assert0(av_i2int(av_shr_i(ai, 17)) == a>>17); +av_assert0(av_i2int(av_shr_i(ai,-17)) == a<<17); +av_assert0(av_log2_i(ai) == av_log2(a)); +av_assert0(av_i2int(av_div_i(ai,bi)) == a/b); +} +#endif /* AVUTIL_TESTS_INTEGER_H */ diff --git a/tools/Makefile b/tools/Makefile index 82baa8eadb..fde7f08984 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -17,6 +17,9 @@ tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c tools/target_io_dem_fuzzer.o: tools/target_dem_fuzzer.c $(COMPILE_C) -DIO_FLAT=0 +tools/target_int_fuzzer.o: tools/target_int_fuzzer.c + $(COMPILE_C) + OUTDIRS += tools clean:: diff --git a/tools/target_int_fuzzer.c b/tools/target_int_fuzzer.c new file mode 100644 index 00..929ae7fae9 --- /dev/null +++ b/tools/target_int_fuzzer.c @@ -0,0 +1,35 @@ +/* + * Copy
Re: [FFmpeg-devel] [PATCH] Add nit flag support
On Mon, 17 May 2021, Ubaldo Porcheddu wrote: Signed-off-by: Ubaldo Porcheddu --- doc/muxers.texi | 2 ++ libavformat/mpegtsenc.c | 96 ++--- 2 files changed, 93 insertions(+), 5 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index e1c6ad0829..f774d972a6 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1876,6 +1876,8 @@ Reemit PAT and PMT at each video frame. Conform to System B (DVB) instead of System A (ATSC). @item initial_discontinuity Mark the initial packet of each stream as discontinuity. +@item nit +Emit NIT table. @end table The new option nit_period is still missing from the docs, please add that as well. @item mpegts_copyts @var{boolean} diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index e3f9d9ad50..68abccf9ca 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -76,10 +76,12 @@ typedef struct MpegTSWrite { const AVClass *av_class; MpegTSSection pat; /* MPEG-2 PAT table */ MpegTSSection sdt; /* MPEG-2 SDT table context */ +MpegTSSection nit; /* MPEG-2 NIT table context */ MpegTSService **services; AVPacket *pkt; int64_t sdt_period; /* SDT period in PCR time base */ int64_t pat_period; /* PAT/PMT period in PCR time base */ +int64_t nit_period; /* NIT period in PCR time base */ int nb_services; int64_t first_pcr; int first_dts_checked; @@ -107,13 +109,18 @@ typedef struct MpegTSWrite { #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES 0x04 #define MPEGTS_FLAG_SYSTEM_B0x08 #define MPEGTS_FLAG_DISCONT 0x10 +#define MPEGTS_FLAG_NIT 0x20 int flags; int copyts; int tables_version; int64_t pat_period_us; int64_t sdt_period_us; +int64_t nit_period_us; int64_t last_pat_ts; int64_t last_sdt_ts; +int64_t last_nit_ts; + +uint8_t provider_name[256]; int omit_video_pes_length; } MpegTSWrite; @@ -227,6 +234,7 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, int id, #define SDT_RETRANS_TIME 500 #define PAT_RETRANS_TIME 100 #define PCR_RETRANS_TIME 20 +#define NIT_RETRANS_TIME 500 typedef struct MpegTSWriteStream { int pid; /* stream associated pid */ @@ -796,6 +804,47 @@ static void mpegts_write_sdt(AVFormatContext *s) data, q - data); } +static void mpegts_write_nit(AVFormatContext *s) +{ +int i; +MpegTSWrite *ts = s->priv_data; +uint8_t data[SECTION_LENGTH], *q, *desc_len_ptr, *loop_len_ptr; +AVProgram *program; + +q = data; + +//network name Use the exact descriptor and field names, e.g.: // network_descriptors_length +put16(&q, 0xf000 | ts->provider_name[0]); // network_name_descriptor +*q++ = 0x40; +putbuf(&q, ts->provider_name, ts->provider_name[0]+1); + +//TS loop +loop_len_ptr = q; +q += 2; +put16(&q, ts->transport_stream_id); +put16(&q, ts->original_network_id); + +//transport descriptor +desc_len_ptr = q; +q += 2; + +//service list descriptor +*q++ = 0x41; +*q++ = 3 * ts->nb_services; +for(i = 0; i < ts->nb_services; i++) { +put16(&q, ts->services[i]->sid); +*q++ = ts->service_type; +program = s->programs[i]; +} + +//calculate lengths +put16(&desc_len_ptr, 0xf000 | q - (desc_len_ptr+2)); +put16(&loop_len_ptr, 0xf000 | q - (loop_len_ptr+2)); + +mpegts_write_section1(&ts->nit, NIT_TID, ts->original_network_id, ts->tables_version, 0, 0, + data, q - data); +} If NIT generation is enabled, then you should also include the NIT PID in PAT for program 0. Please add that. + /* This stores a string in buf with the correct encoding and also sets the * first byte as the length. !str is accepted for an empty string. * If the string is already encoded, invalid UTF-8 or has no multibyte sequence @@ -966,6 +1015,8 @@ static void select_pcr_streams(AVFormatContext *s) static int mpegts_init(AVFormatContext *s) { MpegTSWrite *ts = s->priv_data; +AVDictionaryEntry *provider; +const char *provider_name; int i, j; int ret; @@ -1022,6 +1073,12 @@ static int mpegts_init(AVFormatContext *s) ts->sdt.write_packet = section_write_packet; ts->sdt.opaque = s; +ts->nit.pid = NIT_PID; +ts->nit.cc = 15; +ts->nit.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT; +ts->nit.write_packet = section_write_packet; +ts->nit.opaque = s; + ts->pkt = av_packet_alloc(); if (!ts->pkt) return AVERROR(ENOMEM); @@ -1143,23 +1200,36 @@ static int mpegts_init(AVFormatContext *s) ts->last_pat_ts = AV_NOPTS_VALUE; ts->last_sdt_ts = AV_NOPTS_VALUE; +ts->last_nit_ts = AV_NOPTS_VALUE; ts->pat_period = av_rescale(ts->pat_period_us, PCR_TIME_BASE, AV_TIME_BASE); ts->sdt_period = av_rescale(ts->sdt_period_us, PCR_TIME_BASE, AV_TIME_BASE); +ts->nit_period = av_rescale(ts->nit_period_us, PCR_TIME_
Re: [FFmpeg-devel] [PATCH] avformat/framecrcenc: print basic side data information again
On 5/14/2021 6:27 PM, James Almer wrote: This partially reverts c6ae560a18d67b9ddaa25a0338b7fb55e3312e57. Signed-off-by: James Almer --- libavformat/framecrcenc.c | 8 + tests/ref/fate/copy-trac3074 | 2 +- tests/ref/fate/cover-art-mp3-id3v2-remux | 2 +- tests/ref/fate/gapless-mp3| 6 +- tests/ref/fate/id3v2-priv-remux | 2 +- .../fate/matroska-mastering-display-metadata | 4 +- tests/ref/fate/matroska-spherical-mono-remux | 4 +- tests/ref/fate/matroska-vp8-alpha-remux | 14 +- tests/ref/fate/mov-cover-image| 2 +- tests/ref/fate/mxf-d10-user-comments | 2 +- tests/ref/fate/segment-mp4-to-ts | 250 +- tests/ref/fate/webm-webvtt-remux | 24 +- 12 files changed, 164 insertions(+), 156 deletions(-) Will apply if there are no objections. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1] avcodec/vaapi_av1: correct data size when create slice data buffer
On Mon, 2021-05-17 at 11:59 +0300, Jan Ekström wrote: > On Mon, May 17, 2021 at 4:50 AM Fei Wang wrote: > > > > Set all tiles size to create slice data buffer, hardware will use > > slice_data_offset/slice_data_size in slice parameter buffer to get > > each tile's data. > > > > This change will let it success to decode clip which has multi > > tiles data inside one OBU. > > > > Signed-off-by: Fei Wang > > --- > > libavcodec/vaapi_av1.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c > > index 1809b485aa..16b7e35747 100644 > > --- a/libavcodec/vaapi_av1.c > > +++ b/libavcodec/vaapi_av1.c > > @@ -292,7 +292,7 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx, > > err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, > > sizeof(VASliceParameterBuff > > erAV1), > > buffer, > > -s- > > >tile_group_info[i].tile_size); > > +size); > > if (err) { > > ff_vaapi_decode_cancel(avctx, pic); > > return err; > > -- > > 2.17.1 > > So basically this fixes setting the size of the passed buffer to the > whole size of the buffer (in which tile offset and tile size should > always be located). As such it makes sense. > > It seems like at some point there was an idea to only pass "buffer + > tile_offset", but that never materialized completely (and then setting > VASliceParameterBufferAV1's tile_offset to 0)? Yes, it also works. > Would that lead to smaller buffers being utilized? Or does libva already > extract the tiles into their own buffers based on the information? libva doesn't extract the tiles, it is up to the underlying backend driver. Thanks Haihao > > Jan > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1] avcodec/vaapi_av1: correct data size when create slice data buffer
On Mon, 2021-05-17 at 11:59 +0300, Jan Ekström wrote: > On Mon, May 17, 2021 at 4:50 AM Fei Wang > wrote: > > > > Set all tiles size to create slice data buffer, hardware will use > > slice_data_offset/slice_data_size in slice parameter buffer to get > > each tile's data. > > > > This change will let it success to decode clip which has multi > > tiles data inside one OBU. > > > > Signed-off-by: Fei Wang > > --- > > libavcodec/vaapi_av1.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c > > index 1809b485aa..16b7e35747 100644 > > --- a/libavcodec/vaapi_av1.c > > +++ b/libavcodec/vaapi_av1.c > > @@ -292,7 +292,7 @@ static int > > vaapi_av1_decode_slice(AVCodecContext *avctx, > > err = ff_vaapi_decode_make_slice_buffer(avctx, pic, > > &slice_param, > > sizeof(VASlicePara > > meterBufferAV1), > > buffer, > > -s- > > >tile_group_info[i].tile_size); > > +size); > > if (err) { > > ff_vaapi_decode_cancel(avctx, pic); > > return err; > > -- > > 2.17.1 > > So basically this fixes setting the size of the passed buffer to the > whole size of the buffer (in which tile offset and tile size should > always be located). As such it makes sense. > > It seems like at some point there was an idea to only pass "buffer + > tile_offset", but that never materialized completely (and then > setting > VASliceParameterBufferAV1's tile_offset to 0)? Would that lead to > smaller buffers being utilized? Or does libva already extract the > tiles into their own buffers based on the information? Buffer+tile_offset can fix the issue too. I chose change the size only is to try to follow current logic and do the smallest change to fix this. With buffer+tile_offset way, the buffers will be smaller, but the effect can be ignore, since bitstream size is small. For 8K resolution bitstream, its each frame size is only ~100KB. Fei Thanks > > Jan > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 3/3] avcodec/nvenc: write out user data unregistered SEI
On Monday, 17 May 2021 9:25:10 PM AEST Timo Rothenpieler wrote: > On 17.05.2021 10:19, Brad Hards wrote: > > Signed-off-by: Brad Hards > > --- > > > > libavcodec/nvenc.c | 64 ++ > > 1 file changed, 53 insertions(+), 11 deletions(-) > > > > diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c > > index 0dcd93a99c..e22fdfb5a8 100644 > > --- a/libavcodec/nvenc.c > > +++ b/libavcodec/nvenc.c > > @@ -2170,9 +2170,10 @@ static int nvenc_send_frame(AVCodecContext *avctx, > > const AVFrame *frame)> > > NVENCSTATUS nv_status; > > NvencSurface *tmp_out_surf, *in_surf; > > int res, res2; > > > > -NV_ENC_SEI_PAYLOAD sei_data[8]; > > +NV_ENC_SEI_PAYLOAD *sei_data = 0; > > > > int sei_count = 0; > > int i; > > > > +int total_unregistered_sei = 0; > > > > NvencContext *ctx = avctx->priv_data; > > NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; > > > > @@ -2185,6 +2186,8 @@ static int nvenc_send_frame(AVCodecContext *avctx, > > const AVFrame *frame)> > > return AVERROR(EINVAL); > > > > if (frame && frame->buf[0]) { > > > > +void *a53_data = NULL; > > +void *tc_data = NULL; > > > > in_surf = get_free_frame(ctx); > > if (!in_surf) > > > > return AVERROR(EAGAIN); > > > > @@ -2230,7 +2233,6 @@ static int nvenc_send_frame(AVCodecContext *avctx, > > const AVFrame *frame)> > > pic_params.inputTimeStamp = frame->pts; > > > > if (ctx->a53_cc && av_frame_get_side_data(frame, > > AV_FRAME_DATA_A53_CC)) { > > > > -void *a53_data = NULL; > > > > size_t a53_size = 0; > > > > if (ff_alloc_a53_sei(frame, 0, (void**)&a53_data, &a53_size) > > < 0) { > > > > @@ -2238,15 +2240,21 @@ static int nvenc_send_frame(AVCodecContext *avctx, > > const AVFrame *frame)> > > } > > > > if (a53_data) { > > > > -sei_data[sei_count].payloadSize = (uint32_t)a53_size; > > -sei_data[sei_count].payloadType = 4; > > -sei_data[sei_count].payload = (uint8_t*)a53_data; > > -sei_count ++; > > +sei_data = av_realloc_array(sei_data, sei_count + 1, > > sizeof(NV_ENC_SEI_PAYLOAD)); > Doing this realloc dance every frame is extremely inefficient. > The sei_data array and its current size could instead be stored in the > nvenc context, with a best-guess initial size, and then only grow when > the already allocated size is too small. I recognise that this might be frustrating you. Would you prefer to persist, or would it be easier just to take over the patch and do it the way you want it? I'm fine with either - just let me know. > > +if (!sei_data) { > > +av_free(a53_data); > > +sei_count = 0; > > +return AVERROR(ENOMEM); > > +} else { > > +sei_data[sei_count].payloadSize = (uint32_t)a53_size; > > +sei_data[sei_count].payloadType = 4; > > +sei_data[sei_count].payload = (uint8_t*)a53_data; > > +sei_count ++; > > +} > > > > } > > > > } > > > > if (ctx->s12m_tc && av_frame_get_side_data(frame, > > AV_FRAME_DATA_S12M_TIMECODE)) {> > > -void *tc_data = NULL; > > > > size_t tc_size = 0; > > > > if (ff_alloc_timecode_sei(frame, avctx->framerate, 0, > > (void**)&tc_data, &tc_size) < 0) {> > > @@ -2254,13 +2262,46 @@ static int nvenc_send_frame(AVCodecContext *avctx, > > const AVFrame *frame)> > > } > > > > if (tc_data) { > > > > -sei_data[sei_count].payloadSize = (uint32_t)tc_size; > > -sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; > > -sei_data[sei_count].payload = (uint8_t*)tc_data; > > -sei_count ++; > > +sei_data = av_realloc_array(sei_data, sei_count + 1, > > sizeof(NV_ENC_SEI_PAYLOAD)); +if (!sei_data) { > > +av_free(a53_data); > > +av_free(tc_data); > > +sei_count = 0; > > +return AVERROR(ENOMEM); > > +} else { > > +sei_data[sei_count].payloadSize = (uint32_t)tc_size; > > +sei_data[sei_count].payloadType = SEI_TYPE_TIME_CODE; > > +sei_data[sei_count].payload = (uint8_t*)tc_data; > > +sei_count ++; > > +} > > > > } > > > > } > > > > +for (int j = 0; j < frame->nb_side_data; j++) > > +if (frame->side_data[j]->type == > > AV