Re: [FFmpeg-devel] [PATCH] libavformat/mov.c: export vendor id as metadata
On 18-11-2020 12:16 pm, Thierry Foucu wrote: On Tue, Nov 17, 2020 at 9:54 PM Gyan Doshi wrote: On 18-11-2020 02:41 am, Thierry Foucu wrote: --- libavformat/mov.c | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2b90e31170..1f9163d658 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, uint8_t codec_name[32] = { 0 }; int64_t stsd_start; unsigned int len; +int32_t id = 0; +char vendor_id[5]; /* The first 16 bytes of the video sample description are already * read in ff_mov_read_stsd_entries() */ @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, avio_rb16(pb); /* version */ avio_rb16(pb); /* revision level */ -avio_rb32(pb); /* vendor */ +id = avio_rb32(pb); /* vendor */ +if (id != 0) { +vendor_id[0] = (id >> 24) & 0xff; +vendor_id[1] = (id >> 16) & 0xff; +vendor_id[2] = (id >> 8) & 0xff; +vendor_id[3] = (id >> 0) & 0xff; +vendor_id[4] = 0; +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); +} avio_rb32(pb); /* temporal quality */ avio_rb32(pb); /* spatial quality */ @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, { int bits_per_sample, flags; uint16_t version = avio_rb16(pb); +int32_t id = 0; +char vendor_id[5]; AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); avio_rb16(pb); /* revision level */ -avio_rb32(pb); /* vendor */ +id = avio_rb32(pb); /* vendor */ +if (id != 0) { +vendor_id[0] = (id >> 24) & 0xff; +vendor_id[1] = (id >> 16) & 0xff; +vendor_id[2] = (id >> 8) & 0xff; +vendor_id[3] = (id >> 0) & 0xff; +vendor_id[4] = 0; +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); +} Seems fine. But you likely have to update many FATE refs. FATE fails. See https://patchwork.ffmpeg.org/check/20508/ This automated check stops with the first failure. So check for all tests with '-k' Thanks. I did look at the error but it does not seem related to this patch. Looking at it, i'm not sure how adding vendor ID could break a RGB24 in matroska. The test demuxes a MOV and transcodes streams to MKV. Since your patch adds a metadata entry, that changes the metadata written to the output. Gyan ___ 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] avcodec/cuviddec: fix CUDA_ERROR_INVALID_CONTEXT error found by cuda-memcheck tool
Test command like below: cuda-memcheck ./ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input_file -c:v h264_nvenc -f null - Signed-off-by: leozhang --- libavcodec/cuviddec.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index 5e698d4cd0..816a9c1b3c 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -673,15 +673,27 @@ static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, static av_cold int cuvid_decode_end(AVCodecContext *avctx) { CuvidContext *ctx = avctx->priv_data; +AVHWDeviceContext *device_ctx = (AVHWDeviceContext *)ctx->hwdevice->data; +AVCUDADeviceContext *device_hwctx = device_ctx->hwctx; +CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx; +int ret; av_fifo_freep(&ctx->frame_queue); +ret = CHECK_CU(ctx->cudl->cuCtxPushCurrent(cuda_ctx)); +if (ret < 0) +goto error; + if (ctx->cuparser) ctx->cvdl->cuvidDestroyVideoParser(ctx->cuparser); if (ctx->cudecoder) ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder); +ret = CHECK_CU(ctx->cudl->cuCtxPopCurrent(&dummy)); +if (ret < 0) +goto error; + ctx->cudl = NULL; av_buffer_unref(&ctx->hwframe); @@ -693,6 +705,9 @@ static av_cold int cuvid_decode_end(AVCodecContext *avctx) cuvid_free_functions(&ctx->cvdl); return 0; + +error: +return ret; } static int cuvid_test_capabilities(AVCodecContext *avctx, -- 2.11.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 v2 0/7] HEVC native support for Screen content coding
Hi, Le jeu. 29 oct. 2020 à 14:57, Christophe Gisquet a écrit : > Hi, as you are the only one active on this decoder, this shouldn't matter, > but: > down the line, the ffmpeg project has no way of testing if someone > breaks even the basic parsing of these extensions in the future. > To test, the hardware you mention is needed, as well as maybe specific tests. > > At some point, fate lacks some support for verifying h/w decoding. It > would be really nice if some of these companies with all this new > awesome hardware would consider this, and for instance contribute fate > instances to perform such test for the ffmpeg project. Ping? This is irrespective of the patchset being accepted or not. I just wish people are aware of the stakes in the long term. Thanks anyway for investing the time for what you've already done. -- Christophe ___ 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] lavu/buffer: reuse AVBufferRef alloction
This is an optimization to av_buffer_replace() to avoid a redundant allocation when the src and dst are non-NULL. Instead of doing a unref + ref, the dst buffer is reused and buffer counters updated accordingly. Signed-off-by: Gil Pedersen --- libavutil/buffer.c | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/libavutil/buffer.c b/libavutil/buffer.c index d67b4bbdaf..8f6ba10168 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -219,26 +219,38 @@ int av_buffer_realloc(AVBufferRef **pbuf, int size) int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src) { AVBufferRef *dst = *pdst; -AVBufferRef *tmp; +AVBuffer *b; if (!src) { av_buffer_unref(pdst); return 0; } -if (dst && dst->buffer == src->buffer) { +if (!dst) { +*pdst = av_buffer_ref(src); +if (!*pdst) +return AVERROR(ENOMEM); + +return 0; +} + +if (dst->buffer == src->buffer) { /* make sure the data pointers match */ dst->data = src->data; dst->size = src->size; return 0; } -tmp = av_buffer_ref(src); -if (!tmp) -return AVERROR(ENOMEM); +b = dst->buffer; + +atomic_fetch_add_explicit(&src->buffer->refcount, 1, memory_order_relaxed); + +if (atomic_fetch_sub_explicit(&b->refcount, 1, memory_order_acq_rel) == 1) { +b->free(b->opaque, b->data); +av_freep(&b); +} -av_buffer_unref(pdst); -*pdst = tmp; +*dst = *src; return 0; } -- 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] Next developer meeting
Hi, > we haven't had a meeting for quite some time and are beyond schedule anyway. > So I'd propose having another developer meeting before end of year. > > Please give your preferences for a date here: > https://framadate.org/g1FPmOpfEz9mSLg9 one week later, we have settled for having the FFDev meeting on Saturday, Dec 5th. Based on last time, I told we aim for 17 UTC for the vote. Steven made some comments I don't fully understand... If someone want to shift it, please propose a better time. An overview might be: https://www.timeanddate.de/zeitzonen/konferenz?iso=20201205&p1=224&p2=37&p3=33 > Current agenda proposals, feel free to add to it: > > - Tech / Comm committees how-to in practice > - GSoC adaptations for upcoming years > - splitting libraries (lavf->lavio) > - writing down development rules > - switching to a merge request-like system > - ... -Thilo ___ 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 1/6] avcodec/cbs_av1: use av_buffer_replace() to simplify code
Signed-off-by: Gil Pedersen --- libavcodec/cbs_av1.c | 22 ++ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 9badfe31e4..cf680aed6c 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -896,12 +896,11 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, if (err < 0) return err; -av_buffer_unref(&priv->sequence_header_ref); -priv->sequence_header = NULL; - -priv->sequence_header_ref = av_buffer_ref(unit->content_ref); -if (!priv->sequence_header_ref) -return AVERROR(ENOMEM); +err = av_buffer_replace(&priv->sequence_header_ref, unit->content_ref); +if (err < 0) { +priv->sequence_header = NULL; +return err; +} priv->sequence_header = &obu->obu.sequence_header; } break; @@ -1039,12 +1038,11 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, if (err < 0) return err; -av_buffer_unref(&priv->sequence_header_ref); -priv->sequence_header = NULL; - -priv->sequence_header_ref = av_buffer_ref(unit->content_ref); -if (!priv->sequence_header_ref) -return AVERROR(ENOMEM); +err = av_buffer_replace(&priv->sequence_header_ref, unit->content_ref); +if (err < 0) { +priv->sequence_header = NULL; +return err; +} priv->sequence_header = &obu->obu.sequence_header; } break; -- 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".
[FFmpeg-devel] [PATCH 3/6] avcodec/h264_parser: use av_buffer_replace() to simplify code
Signed-off-by: Gil Pedersen --- libavcodec/h264_parser.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index aacd44cf3b..f39924595e 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -360,12 +360,12 @@ static inline int parse_nal_units(AVCodecParserContext *s, goto fail; } -av_buffer_unref(&p->ps.pps_ref); -p->ps.pps = NULL; -p->ps.sps = NULL; -p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]); -if (!p->ps.pps_ref) +ret = av_buffer_replace(&p->ps.pps_ref, p->ps.pps_list[pps_id]); +if (ret < 0) { +p->ps.pps = NULL; +p->ps.sps = NULL; goto fail; +} p->ps.pps = (const PPS*)p->ps.pps_ref->data; p->ps.sps = p->ps.pps->sps; sps = p->ps.sps; -- 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".
[FFmpeg-devel] [PATCH 4/6] avcodec/h264_slice: use av_buffer_replace() to simplify code
Signed-off-by: Gil Pedersen --- libavcodec/h264_slice.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index fa7a639053..b937ebebcf 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1018,11 +1018,11 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl int needs_reinit = 0, must_reinit, ret; if (first_slice) { -av_buffer_unref(&h->ps.pps_ref); -h->ps.pps = NULL; -h->ps.pps_ref = av_buffer_ref(h->ps.pps_list[sl->pps_id]); -if (!h->ps.pps_ref) -return AVERROR(ENOMEM); +ret = av_buffer_replace(&h->ps.pps_ref, h->ps.pps_list[sl->pps_id]); +if (ret < 0) { +h->ps.pps = NULL; +return ret; +} h->ps.pps = (const PPS*)h->ps.pps_ref->data; } -- 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".
[FFmpeg-devel] [PATCH 5/6] avcodec/wavpack: use av_buffer_replace() to simplify code
Signed-off-by: Gil Pedersen --- libavcodec/wavpack.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index f77548e5a5..58122c948c 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1024,13 +1024,12 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) return ret; } -av_buffer_unref(&fdst->dsd_ref); fdst->dsdctx = NULL; fdst->dsd_channels = 0; +ret = av_buffer_replace(&fdst->dsd_ref, fsrc->dsd_ref); +if (ret < 0) +return ret; if (fsrc->dsd_ref) { -fdst->dsd_ref = av_buffer_ref(fsrc->dsd_ref); -if (!fdst->dsd_ref) -return AVERROR(ENOMEM); fdst->dsdctx = (DSDContext*)fdst->dsd_ref->data; fdst->dsd_channels = fsrc->dsd_channels; } -- 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".
[FFmpeg-devel] [PATCH 6/6] avutil/frame: use av_buffer_replace() to simplify code
Also fixes potential leaks in failing av_frame_ref(). Signed-off-by: Gil Pedersen --- libavutil/frame.c | 37 - 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 3ab1aa3242..b019779b1a 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -349,7 +349,7 @@ int av_frame_get_buffer(AVFrame *frame, int align) static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy) { -int i; +int ret, i; dst->key_frame = src->key_frame; dst->pict_type = src->pict_type; @@ -426,31 +426,18 @@ FF_DISABLE_DEPRECATION_WARNINGS dst->qscale_table = NULL; dst->qstride = 0; dst->qscale_type = 0; -av_buffer_unref(&dst->qp_table_buf); -if (src->qp_table_buf) { -dst->qp_table_buf = av_buffer_ref(src->qp_table_buf); -if (dst->qp_table_buf) { -dst->qscale_table = dst->qp_table_buf->data; -dst->qstride = src->qstride; -dst->qscale_type = src->qscale_type; -} +av_buffer_replace(&dst->qp_table_buf, src->qp_table_buf); +if (dst->qp_table_buf) { +dst->qscale_table = dst->qp_table_buf->data; +dst->qstride = src->qstride; +dst->qscale_type = src->qscale_type; } FF_ENABLE_DEPRECATION_WARNINGS #endif -av_buffer_unref(&dst->opaque_ref); -av_buffer_unref(&dst->private_ref); -if (src->opaque_ref) { -dst->opaque_ref = av_buffer_ref(src->opaque_ref); -if (!dst->opaque_ref) -return AVERROR(ENOMEM); -} -if (src->private_ref) { -dst->private_ref = av_buffer_ref(src->private_ref); -if (!dst->private_ref) -return AVERROR(ENOMEM); -} -return 0; +ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref); +ret |= av_buffer_replace(&dst->private_ref, src->private_ref); +return ret; } int av_frame_ref(AVFrame *dst, const AVFrame *src) @@ -469,17 +456,17 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) ret = frame_copy_props(dst, src, 0); if (ret < 0) -return ret; +goto fail; /* duplicate the frame data if it's not refcounted */ if (!src->buf[0]) { ret = av_frame_get_buffer(dst, 0); if (ret < 0) -return ret; +goto fail; ret = av_frame_copy(dst, src); if (ret < 0) -av_frame_unref(dst); +goto fail; return ret; } -- 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".
[FFmpeg-devel] [PATCH 0/6] Use av_buffer_replace()
Included are six patches to refactor code to use av_buffer_replace(). This is extra relevant if my 'reuse AVBufferRef alloction' patch is merged. /Gil Gil Pedersen (6): avcodec/cbs_av1: use av_buffer_replace() to simplify code avcodec/cbs_h2645: use av_buffer_replace() to simplify code avcodec/h264_parser: use av_buffer_replace() to simplify code avcodec/h264_slice: use av_buffer_replace() to simplify code avcodec/wavpack: use av_buffer_replace() to simplify code avutil/frame: use av_buffer_replace() to simplify code libavcodec/cbs_av1.c | 22 ++ libavcodec/cbs_h2645.c | 7 +++ libavcodec/h264_parser.c | 10 +- libavcodec/h264_slice.c | 10 +- libavcodec/wavpack.c | 7 +++ libavutil/frame.c| 37 - 6 files changed, 38 insertions(+), 55 deletions(-) -- 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".
[FFmpeg-devel] [PATCH 2/6] avcodec/cbs_h2645: use av_buffer_replace() to simplify code
Signed-off-by: Gil Pedersen --- libavcodec/cbs_h2645.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index b6d77dd17f..09841af5e6 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -665,11 +665,10 @@ static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ return err; \ if (priv->ps_var[id] == priv->active_ ## ps_var) \ priv->active_ ## ps_var = NULL ; \ -av_buffer_unref(&priv->ps_var ## _ref[id]); \ +err = av_buffer_replace(&priv->ps_var ## _ref[id], unit->content_ref); \ av_assert0(unit->content_ref); \ -priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \ -if (!priv->ps_var ## _ref[id]) \ -return AVERROR(ENOMEM); \ +if (err < 0) \ +return err; \ priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## _ref[id]->data; \ if (!unit->content_ref) \ memcpy(priv->ps_var[id], ps_var, sizeof(*ps_var)); \ -- 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] lavu/buffer: reuse AVBufferRef alloction
Quoting Gil Pedersen (2020-11-18 12:24:09) > This is an optimization to av_buffer_replace() to avoid a redundant allocation > when the src and dst are non-NULL. > > Instead of doing a unref + ref, the dst buffer is reused and buffer counters > updated accordingly. > > Signed-off-by: Gil Pedersen > --- > libavutil/buffer.c | 26 +++--- > 1 file changed, 19 insertions(+), 7 deletions(-) Is there a reason to think this optimization has a measurable effect on performance? The code that fiddles with buffer internals should ideally be localized in as few places as possible, your patch is spreading it. I'd like to hear some arguments for why that is worth it. -- Anton Khirnov ___ 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 087/114] avcodec/vc1: Avoid code duplication when initializing VLCs
I don't think it is a good idea to change the format of the table to something different than the tables in the SMPTE VC-1 documentation. People fluent in this documentation have a hard time correlating the new tables to the 'official' ones. --- Regards, Jerome This has been achieved by switching those VLCs that still used ff_init_vlc_sparse() to ff_init_vlc_lengths() even though the codes tables used uint8_t in these cases. But it allows to use one auxiliary function to initialize the VLCs and by using tables that interleave symbols and lengths said function only needs one parameter for the tables, not two. The only table that uses an uint16_t symbols table still has to be treated specially for this reason. The offsets table has been removed as a byproduct of these changes. Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1.c | 158 +++--- libavcodec/vc1data.c | 159 +-- libavcodec/vc1data.h | 21 ++ 3 files changed, 138 insertions(+), 200 deletions(-) ... /* 4MV Block pattern VLC tables */ -const uint8_t ff_vc1_4mv_block_pattern_codes[4][16] = { -{ 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2 }, -{ 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0 }, -{ 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0 }, -{ 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10 } -}; -const uint8_t ff_vc1_4mv_block_pattern_bits[4][16] = { -{ 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2 }, -{ 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2 }, -{ 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3 }, -{ 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4 } +const uint8_t ff_vc1_4mv_block_pattern_tabs[4][16][2] = { +{ +{ 0x0B, 3 }, { 0x0D, 3 }, { 0x0E, 3 }, { 0x04, 5 }, { 0x08, 5 }, +{ 0x00, 5 }, { 0x06, 5 }, { 0x0F, 2 }, { 0x09, 5 }, { 0x03, 5 }, +{ 0x05, 5 }, { 0x0A, 5 }, { 0x0C, 5 }, { 0x01, 6 }, { 0x02, 6 }, +{ 0x07, 4 }, +}, +{ +{ 0x0F, 2 }, { 0x03, 4 }, { 0x05, 4 }, { 0x0A, 4 }, { 0x0C, 4 }, +{ 0x00, 4 }, { 0x01, 5 }, { 0x02, 5 }, { 0x04, 5 }, { 0x08, 5 }, +{ 0x07, 4 }, { 0x0B, 4 }, { 0x0D, 4 }, { 0x0E, 4 }, { 0x06, 5 }, +{ 0x09, 5 }, +}, +{ +{ 0x0F, 3 }, { 0x03, 4 }, { 0x05, 4 }, { 0x0A, 4 }, { 0x0C, 4 }, +{ 0x01, 4 }, { 0x02, 4 }, { 0x04, 4 }, { 0x07, 4 }, { 0x08, 4 }, +{ 0x0B, 4 }, { 0x0D, 4 }, { 0x0E, 4 }, { 0x06, 5 }, { 0x09, 5 }, +{ 0x00, 4 }, +}, +{ +{ 0x00, 2 }, { 0x03, 4 }, { 0x05, 4 }, { 0x0A, 4 }, { 0x0C, 4 }, +{ 0x07, 5 }, { 0x0B, 5 }, { 0x0D, 5 }, { 0x0E, 5 }, { 0x0F, 4 }, +{ 0x01, 4 }, { 0x02, 4 }, { 0x04, 4 }, { 0x08, 4 }, { 0x06, 5 }, +{ 0x09, 5 }, +}, }; /* 2MV Block pattern VLC tables */ -const uint8_t ff_vc1_2mv_block_pattern_codes[4][4] = { -{ 2, 1, 0, 3 }, { 1, 0, 2, 3 }, { 2, 0, 3, 1 }, { 1, 3, 2, 0 } -}; - -const uint8_t ff_vc1_2mv_block_pattern_bits[4][4] = { -{ 2, 2, 2, 2 }, { 1, 2, 3, 3 }, { 3, 2, 3, 1 }, { 1, 3, 3, 2 } +const uint8_t ff_vc1_2mv_block_pattern_tabs[4][4][2] = { +{ { 0x02, 2 }, { 0x01, 2 }, { 0x00, 2 }, { 0x03, 2 } }, +{ { 0x01, 2 }, { 0x02, 3 }, { 0x03, 3 }, { 0x00, 1 } }, +{ { 0x01, 2 }, { 0x00, 3 }, { 0x02, 3 }, { 0x03, 1 } }, +{ { 0x03, 2 }, { 0x02, 3 }, { 0x01, 3 }, { 0x00, 1 } }, }; /* Interlaced frame picture 4MV MBMODE VLC tables (tables 160-163) */ @@ -350,46 +349,42 @@ const uint8_t ff_vc1_intfr_non4mv_mbmode_tabs[4][9][2] = { /* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */ /* mixed-MV */ -const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8] = { -{ 16, 17, 3, 3, 0, 5, 9, 2 }, -{ 8, 9, 3, 6, 7, 0, 5, 2 }, -{ 16, 17, 5, 3, 0, 3, 9, 2 }, -{ 56, 57, 15, 4, 5, 6, 29, 0 }, -{ 52, 53, 27, 14, 15, 2, 12, 0 }, -{ 56, 57, 29, 5, 6, 0, 15, 4 }, -{ 16, 17, 6, 7, 0, 1, 9, 5 }, -{ 56, 57, 0, 5, 6, 29, 4, 15 } -}; -const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8] = { -{ 6, 6, 2, 3, 2, 4, 5, 2 }, -{ 5, 5, 3, 3, 3, 2, 4, 2 }, -{ 6, 6, 4, 3, 2, 2, 5, 2 }, -{ 6, 6, 4, 3, 3, 3, 5, 1 }, -{ 6, 6, 5, 4, 4, 2, 4, 1 }, -{ 6, 6, 5, 3, 3, 1, 4, 3 }, -{ 5, 5, 3, 3, 2, 2, 4, 3 }, -{ 6, 6, 1, 3, 3, 5, 3, 4 } +const uint8_t ff_vc1_if_mmv_mbmode_tabs[8][8][2] = { +{ { 0x04, 2 }, { 0x00, 6 }, { 0x01, 6 }, { 0x06, 5 }, + { 0x05, 4 }, { 0x03, 3 }, { 0x07, 2 }, { 0x02, 2 } }, +{ { 0x05, 2 }, { 0x00, 5 }, { 0x01, 5 }, { 0x06, 4 }, + { 0x02, 3 }, { 0x07, 2 }, { 0x03, 3 }, { 0x04, 3 } }, +{ { 0x04, 2 }, { 0x00, 6 }, { 0x01, 6 }, { 0x06, 5 }, + { 0x02, 4 }, { 0x03, 3 }, { 0x07, 2 }, { 0x05, 2 } }, +{ { 0x07, 1 }, { 0x03, 3 }, { 0x04, 3 }, { 0x05, 3 }, + { 0x00, 6 }, { 0x01, 6 }, { 0x06, 5 }, { 0x02, 4 } }, +{ { 0x07, 1 }, { 0x05, 2 }, { 0x06, 4 }, { 0x00, 6 }, + { 0x01, 6
[FFmpeg-devel] [PATCH 05/18] avcodec/decode: port to the new packet list API
Signed-off-by: James Almer --- libavcodec/decode.c | 20 ++-- libavcodec/internal.h | 4 +--- libavcodec/utils.c| 11 ++- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 5a1849f944..8a81280e7c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -147,19 +147,21 @@ fail2: static int extract_packet_props(AVCodecInternal *avci, AVPacket *pkt) { +#if FF_API_PACKET_LIST +struct PacketList *pkt_props = (struct PacketList *)avci->pkt_props; +#else +AVPacketList *pkt_props = avci->pkt_props; +#endif int ret = 0; -ret = avpriv_packet_list_put(&avci->pkt_props, &avci->pkt_props_tail, pkt, - av_packet_copy_props, 0); +ret = av_packet_list_put(avci->pkt_props, pkt, av_packet_copy_props, 0); if (ret < 0) return ret; -avci->pkt_props_tail->pkt.size = pkt->size; // HACK: Needed for ff_decode_frame_props(). -avci->pkt_props_tail->pkt.data = (void*)1; // HACK: Needed for IS_EMPTY(). +pkt_props->tail->pkt.size = pkt->size; // HACK: Needed for ff_decode_frame_props(). +pkt_props->tail->pkt.data = (void*)1; // HACK: Needed for IS_EMPTY(). if (IS_EMPTY(avci->last_pkt_props)) { -ret = avpriv_packet_list_get(&avci->pkt_props, - &avci->pkt_props_tail, - avci->last_pkt_props); +ret = av_packet_list_get(avci->pkt_props, avci->last_pkt_props, 0); av_assert0(ret != AVERROR(EAGAIN)); } return ret; @@ -1722,9 +1724,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) }; if (IS_EMPTY(pkt)) -avpriv_packet_list_get(&avctx->internal->pkt_props, - &avctx->internal->pkt_props_tail, - pkt); +av_packet_list_get(avctx->internal->pkt_props, pkt, 0); if (pkt) { frame->pts = pkt->pts; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index c72cce869e..e7d1d9ccb5 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -31,7 +31,6 @@ #include "libavutil/mathematics.h" #include "libavutil/pixfmt.h" #include "avcodec.h" -#include "packet_internal.h" #include "config.h" /** @@ -146,8 +145,7 @@ typedef struct AVCodecInternal { * for decoding. */ AVPacket *last_pkt_props; -PacketListEntry *pkt_props; -PacketListEntry *pkt_props_tail; +AVPacketList *pkt_props; /** * temporary buffer used for encoders to store their bitstream diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9b074e2dda..42e6850169 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -593,10 +593,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code avci->es.in_frame = av_frame_alloc(); avci->ds.in_pkt = av_packet_alloc(); avci->last_pkt_props = av_packet_alloc(); +avci->pkt_props = av_packet_list_alloc(); if (!avci->compat_decode_frame || !avci->compat_encode_packet || !avci->buffer_frame || !avci->buffer_pkt || !avci->es.in_frame || !avci->ds.in_pkt || -!avci->to_free || !avci->last_pkt_props) { +!avci->to_free || !avci->last_pkt_props || +!avci->pkt_props) { ret = AVERROR(ENOMEM); goto free_and_end; } @@ -1054,6 +1056,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_packet_free(&avci->compat_encode_packet); av_packet_free(&avci->buffer_pkt); av_packet_free(&avci->last_pkt_props); +av_packet_list_free(&avci->pkt_props); av_packet_free(&avci->ds.in_pkt); av_frame_free(&avci->es.in_frame); @@ -1094,8 +1097,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) av_packet_unref(avci->buffer_pkt); av_packet_unref(avci->last_pkt_props); -avpriv_packet_list_free(&avci->pkt_props, -&avci->pkt_props_tail); +av_packet_list_flush(avci->pkt_props); av_frame_unref(avci->es.in_frame); av_packet_unref(avci->ds.in_pkt); @@ -1158,8 +1160,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_packet_free(&avctx->internal->compat_encode_packet); av_packet_free(&avctx->internal->buffer_pkt); av_packet_free(&avctx->internal->last_pkt_props); -avpriv_packet_list_free(&avctx->internal->pkt_props, -&avctx->internal->pkt_props_tail); +av_packet_list_free(&avctx->internal->pkt_props); av_packet_free(&avctx->internal->ds.in_pkt); av_frame_free(&avctx->internal->es.in_frame); -- 2.29.2 ___ 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 09/18] avdevice/dshow: port to the new packet list API
Signed-off-by: James Almer --- libavdevice/dshow.c | 52 + 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index d7f5bd7069..ab158b13b6 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -58,7 +58,6 @@ static int dshow_read_close(AVFormatContext *s) { struct dshow_ctx *ctx = s->priv_data; -AVPacketList *pktl; if (ctx->control) { IMediaControl_Stop(ctx->control); @@ -116,13 +115,7 @@ dshow_read_close(AVFormatContext *s) if(ctx->event[1]) CloseHandle(ctx->event[1]); -pktl = ctx->pktl; -while (pktl) { -AVPacketList *next = pktl->next; -av_packet_unref(&pktl->pkt); -av_free(pktl); -pktl = next; -} +av_packet_list_free(&ctx->pktl); CoUninitialize(); @@ -162,7 +155,8 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e { AVFormatContext *s = priv_data; struct dshow_ctx *ctx = s->priv_data; -AVPacketList **ppktl, *pktl_next; +AVPacket pkt = { 0 }; +int ret; //dump_videohdr(s, vdhdr); @@ -171,21 +165,19 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e if(shall_we_drop(s, index, devtype)) goto fail; -pktl_next = av_mallocz(sizeof(AVPacketList)); -if(!pktl_next) +if (av_new_packet(&pkt, buf_size) < 0) goto fail; -if(av_new_packet(&pktl_next->pkt, buf_size) < 0) { -av_free(pktl_next); +pkt.stream_index = index; +pkt.pts = time; +memcpy(pkt.data, buf, buf_size); + +ret = av_packet_list_put(ctx->pktl, &pkt, NULL, 0); +if (ret < 0) { +av_packet_unref(&pkt); goto fail; } -pktl_next->pkt.stream_index = index; -pktl_next->pkt.pts = time; -memcpy(pktl_next->pkt.data, buf, buf_size); - -for(ppktl = &ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->next); -*ppktl = pktl_next; ctx->curbufsize[index] += buf_size; SetEvent(ctx->event[1]); @@ -1113,6 +1105,12 @@ static int dshow_read_header(AVFormatContext *avctx) } } +ctx->pktl = av_packet_list_alloc(); +if (!ctx->pktl) { +ret = AVERROR(ENOMEM); +goto error; +} + r = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (void **) &graph); if (r != S_OK) { @@ -1262,20 +1260,18 @@ static int dshow_check_event_queue(IMediaEvent *media_event) static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt) { struct dshow_ctx *ctx = s->priv_data; -AVPacketList *pktl = NULL; +int ret = AVERROR(EAGAIN); -while (!ctx->eof && !pktl) { +while (!ctx->eof && ret) { WaitForSingleObject(ctx->mutex, INFINITE); -pktl = ctx->pktl; -if (pktl) { -*pkt = pktl->pkt; -ctx->pktl = ctx->pktl->next; -av_free(pktl); + +ret = av_packet_list_get(ctx->pktl, pkt, 0); +if (!ret) ctx->curbufsize[pkt->stream_index] -= pkt->size; -} + ResetEvent(ctx->event[1]); ReleaseMutex(ctx->mutex); -if (!pktl) { +if (ret) { if (dshow_check_event_queue(ctx->media_event) < 0) { ctx->eof = 1; } else if (s->flags & AVFMT_FLAG_NONBLOCK) { -- 2.29.2 ___ 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 11/18] avdevice/vfwcap: port to the new packet list API
Signed-off-by: James Almer --- libavdevice/vfwcap.c | 49 +++- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index e2ab276c2e..eb5c29923f 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -178,7 +178,8 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr) { AVFormatContext *s; struct vfw_ctx *ctx; -AVPacketList **ppktl, *pktl_next; +AVPacket pkt = { 0 }; +int ret; s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA); ctx = s->priv_data; @@ -190,21 +191,18 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr) WaitForSingleObject(ctx->mutex, INFINITE); -pktl_next = av_mallocz(sizeof(AVPacketList)); -if(!pktl_next) +if (av_new_packet(&pkt, vdhdr->dwBytesUsed) < 0) goto fail; -if(av_new_packet(&pktl_next->pkt, vdhdr->dwBytesUsed) < 0) { -av_free(pktl_next); +pkt.pts = vdhdr->dwTimeCaptured; +memcpy(pkt.data, vdhdr->lpData, vdhdr->dwBytesUsed); + +ret = av_packet_list_put(ctx->pktl, &pkt, NULL, 0); +if (ret < 0) { +av_packet_unref(&pkt); goto fail; } -pktl_next->pkt.pts = vdhdr->dwTimeCaptured; -memcpy(pktl_next->pkt.data, vdhdr->lpData, vdhdr->dwBytesUsed); - -for(ppktl = &ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->next); -*ppktl = pktl_next; - ctx->curbufsize += vdhdr->dwBytesUsed; SetEvent(ctx->event); @@ -219,7 +217,6 @@ fail: static int vfw_read_close(AVFormatContext *s) { struct vfw_ctx *ctx = s->priv_data; -AVPacketList *pktl; if(ctx->hwnd) { SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0); @@ -231,13 +228,7 @@ static int vfw_read_close(AVFormatContext *s) if(ctx->event) CloseHandle(ctx->event); -pktl = ctx->pktl; -while (pktl) { -AVPacketList *next = pktl->next; -av_packet_unref(&pktl->pkt); -av_free(pktl); -pktl = next; -} +av_packet_list_free(&ctx->pktl); return 0; } @@ -300,6 +291,13 @@ static int vfw_read_header(AVFormatContext *s) SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s); + +ctx->pktl = av_packet_list_alloc(); +if (!ctx->pktl) { +vfw_read_close(s); +return AVERROR(ENOMEM); +} + st = avformat_new_stream(s, NULL); if(!st) { vfw_read_close(s); @@ -439,19 +437,14 @@ fail: static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt) { struct vfw_ctx *ctx = s->priv_data; -AVPacketList *pktl = NULL; +int ret = AVERROR(EAGAIN); -while(!pktl) { +while (ret) { WaitForSingleObject(ctx->mutex, INFINITE); -pktl = ctx->pktl; -if(ctx->pktl) { -*pkt = ctx->pktl->pkt; -ctx->pktl = ctx->pktl->next; -av_free(pktl); -} +ret = av_packet_list_get(ctx->pktl, pkt, 0); ResetEvent(ctx->event); ReleaseMutex(ctx->mutex); -if(!pktl) { +if (ret) { if(s->flags & AVFMT_FLAG_NONBLOCK) { return AVERROR(EAGAIN); } else { -- 2.29.2 ___ 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 12/18] avformat/ttaenc: port to the new packet list API
Signed-off-by: James Almer --- libavformat/ttaenc.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c index 39d9034f68..8abba11aed 100644 --- a/libavformat/ttaenc.c +++ b/libavformat/ttaenc.c @@ -30,7 +30,7 @@ typedef struct TTAMuxContext { AVIOContext *seek_table; -PacketListEntry *queue, *queue_end; +AVPacketList *queue; uint32_t nb_samples; int frame_size; int last_frame; @@ -64,6 +64,10 @@ static int tta_init(AVFormatContext *s) tta->frame_size = par->sample_rate * 256 / 245; avpriv_set_pts_info(s->streams[0], 64, 1, par->sample_rate); +tta->queue = av_packet_list_alloc(); +if (!tta->queue) +return AVERROR(ENOMEM); + return 0; } @@ -94,8 +98,7 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt) TTAMuxContext *tta = s->priv_data; int ret; -ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt, - av_packet_ref, 0); +ret = av_packet_list_put(tta->queue, pkt, av_packet_ref, 0); if (ret < 0) { return ret; } @@ -125,8 +128,7 @@ static void tta_queue_flush(AVFormatContext *s) TTAMuxContext *tta = s->priv_data; AVPacket pkt; -while (tta->queue) { -avpriv_packet_list_get(&tta->queue, &tta->queue_end, &pkt); +while (!av_packet_list_get(tta->queue, &pkt, 0)) { avio_write(s->pb, pkt.data, pkt.size); av_packet_unref(&pkt); } @@ -162,7 +164,7 @@ static void tta_deinit(AVFormatContext *s) TTAMuxContext *tta = s->priv_data; ffio_free_dyn_buf(&tta->seek_table); -avpriv_packet_list_free(&tta->queue, &tta->queue_end); +av_packet_list_free(&tta->queue); } AVOutputFormat ff_tta_muxer = { -- 2.29.2 ___ 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 13/18] avformat/mp3enc: port to the new packet list API
Signed-off-by: James Almer --- libavformat/mp3enc.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index fddde33400..ed585c3976 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -132,7 +132,7 @@ typedef struct MP3Context { int pics_to_write; /* audio packets are queued here until we get all the attached pictures */ -PacketListEntry *queue, *queue_end; +AVPacketList *queue; } MP3Context; static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}}; @@ -387,8 +387,7 @@ static int mp3_queue_flush(AVFormatContext *s) ff_id3v2_finish(&mp3->id3, s->pb, s->metadata_header_padding); mp3_write_xing(s); -while (mp3->queue) { -avpriv_packet_list_get(&mp3->queue, &mp3->queue_end, &pkt); +while (!av_packet_list_get(mp3->queue, &pkt, 0)) { if (write && (ret = mp3_write_audio_packet(s, &pkt)) < 0) write = 0; av_packet_unref(&pkt); @@ -523,7 +522,7 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->stream_index == mp3->audio_stream_idx) { if (mp3->pics_to_write) { /* buffer audio packets until we get all the pictures */ -int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end, pkt, av_packet_ref, 0); +int ret = av_packet_list_put(mp3->queue, pkt, av_packet_ref, 0); if (ret < 0) { av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n"); @@ -603,6 +602,10 @@ static int mp3_init(struct AVFormatContext *s) return AVERROR(EINVAL); } +mp3->queue = av_packet_list_alloc(); +if (!mp3->queue) +return AVERROR(ENOMEM); + return 0; } @@ -631,7 +634,7 @@ static void mp3_deinit(struct AVFormatContext *s) { MP3Context *mp3 = s->priv_data; -avpriv_packet_list_free(&mp3->queue, &mp3->queue_end); +av_packet_list_free(&mp3->queue); av_freep(&mp3->xing_frame); } -- 2.29.2 ___ 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 15/18] avformat/aiffenc: port to the new packet list API
Signed-off-by: James Almer --- libavformat/aiffenc.c | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 7c28109814..4fa77c21bf 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -37,7 +37,7 @@ typedef struct AIFFOutputContext { int64_t frames; int64_t ssnd; int audio_stream_idx; -PacketListEntry *pict_list, *pict_list_end; +AVPacketList *pict_list; int write_id3v2; int id3v2_version; } AIFFOutputContext; @@ -47,10 +47,10 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff) int ret; uint64_t pos, end, size; ID3v2EncContext id3v2 = { 0 }; +AVPacket pkt; AVIOContext *pb = s->pb; -PacketListEntry *pict_list = aiff->pict_list; -if (!s->metadata && !s->nb_chapters && !aiff->pict_list) +if (!s->metadata && !s->nb_chapters && av_packet_list_peek(aiff->pict_list, NULL, 0)) return 0; avio_wl32(pb, MKTAG('I', 'D', '3', ' ')); @@ -59,10 +59,11 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff) ff_id3v2_start(&id3v2, pb, aiff->id3v2_version, ID3v2_DEFAULT_MAGIC); ff_id3v2_write_metadata(s, &id3v2); -while (pict_list) { -if ((ret = ff_id3v2_write_apic(s, &id3v2, &pict_list->pkt)) < 0) +while (!av_packet_list_get(aiff->pict_list, &pkt, 0)) { +ret = ff_id3v2_write_apic(s, &id3v2, &pkt); +av_packet_unref(&pkt); +if (ret < 0) return ret; -pict_list = pict_list->next; } ff_id3v2_finish(&id3v2, pb, s->metadata_header_padding); @@ -119,6 +120,10 @@ static int aiff_write_header(AVFormatContext *s) return AVERROR(EINVAL); } +aiff->pict_list = av_packet_list_alloc(); +if (!aiff->pict_list) +return AVERROR(ENOMEM); + par = s->streams[aiff->audio_stream_idx]->codecpar; /* First verify if format is ok */ @@ -221,8 +226,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) if (s->streams[pkt->stream_index]->nb_frames >= 1) return 0; -return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end, - pkt, av_packet_ref, 0); +return av_packet_list_put(aiff->pict_list, pkt, av_packet_ref, 0); } return 0; @@ -273,7 +277,7 @@ static void aiff_deinit(AVFormatContext *s) { AIFFOutputContext *aiff = s->priv_data; -avpriv_packet_list_free(&aiff->pict_list, &aiff->pict_list_end); +av_packet_list_free(&aiff->pict_list); } #define OFFSET(x) offsetof(AIFFOutputContext, x) -- 2.29.2 ___ 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 16/18] avformat/matroskadec: port to the new packet list API
Signed-off-by: James Almer --- libavformat/matroskadec.c | 31 ++- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 0970e1d1ef..4be31daa93 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -366,8 +366,7 @@ typedef struct MatroskaDemuxContext { int64_t segment_start; /* the packet queue */ -PacketListEntry *queue; -PacketListEntry *queue_end; +AVPacketList *queue; int done; @@ -2872,6 +2871,10 @@ static int matroska_read_header(AVFormatContext *s) } ebml_free(ebml_syntax, &ebml); +matroska->queue = av_packet_list_alloc(); +if (!matroska->queue) +return AVERROR(ENOMEM); + /* The next thing is a segment. */ pos = avio_tell(matroska->ctx->pb); res = ebml_parse(matroska, matroska_segments, matroska); @@ -2988,11 +2991,10 @@ fail: static int matroska_deliver_packet(MatroskaDemuxContext *matroska, AVPacket *pkt) { -if (matroska->queue) { +if (!av_packet_list_get(matroska->queue, pkt, 0)) { MatroskaTrack *tracks = matroska->tracks.elem; MatroskaTrack *track; -avpriv_packet_list_get(&matroska->queue, &matroska->queue_end, pkt); track = &tracks[pkt->stream_index]; if (track->has_palette) { uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); @@ -3014,7 +3016,7 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska, */ static void matroska_clear_queue(MatroskaDemuxContext *matroska) { -avpriv_packet_list_free(&matroska->queue, &matroska->queue_end); +av_packet_list_flush(matroska->queue); } static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, @@ -3180,7 +3182,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska, track->audio.buf_timecode = AV_NOPTS_VALUE; pkt->pos = pos; pkt->stream_index = st->index; -ret = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0); +ret = av_packet_list_put(matroska->queue, pkt, NULL, 0); if (ret < 0) { av_packet_unref(pkt); return AVERROR(ENOMEM); @@ -3402,7 +3404,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, pkt->duration = duration; pkt->pos = pos; -err = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0); +err = av_packet_list_put(matroska->queue, pkt, NULL, 0); if (err < 0) { av_packet_unref(pkt); return AVERROR(ENOMEM); @@ -3513,7 +3515,7 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif -res = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0); +res = av_packet_list_put(matroska->queue, pkt, NULL, 0); if (res < 0) { av_packet_unref(pkt); return AVERROR(ENOMEM); @@ -3823,6 +3825,7 @@ static int matroska_read_close(AVFormatContext *s) int n; matroska_clear_queue(matroska); +av_packet_list_free(&matroska->queue); for (n = 0; n < matroska->tracks.nb_elem; n++) if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO) @@ -3886,8 +3889,8 @@ static int webm_clusters_start_with_keyframe(AVFormatContext *s) before_pos = avio_tell(s->pb); while (1) { uint64_t cluster_id, cluster_length; -int read; -AVPacket *pkt; +int read, flags; +AVPacket pkt; avio_seek(s->pb, cluster_pos, SEEK_SET); // read cluster id and length read = ebml_read_num(matroska, matroska->ctx->pb, 4, &cluster_id, 1); @@ -3900,13 +3903,15 @@ static int webm_clusters_start_with_keyframe(AVFormatContext *s) matroska_reset_status(matroska, 0, cluster_pos); matroska_clear_queue(matroska); if (matroska_parse_cluster(matroska) < 0 || -!matroska->queue) { +av_packet_list_peek(matroska->queue, NULL, 0)) { break; } -pkt = &matroska->queue->pkt; +av_packet_list_peek(matroska->queue, &pkt, 0); +flags = pkt.flags; +av_packet_unref(&pkt); // 4 + read is the length of the cluster id and the cluster length field. cluster_pos += 4 + read + cluster_length; -if (!(pkt->flags & AV_PKT_FLAG_KEY)) { +if (!(flags & AV_PKT_FLAG_KEY)) { rv = 0; break; } -- 2.29.2 ___ 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 17/18] avcodec/avpacket: schedule the removal of avpriv_packet_list_*
Signed-off-by: James Almer --- Maybe we can remove this right away? It's not in any release. libavcodec/avpacket.c| 2 ++ libavcodec/packet_internal.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index c79200b63b..0db47c1d62 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -726,6 +726,7 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif } +#if LIBAVCODEC_VERSION_MAJOR < 59 int avpriv_packet_list_put(PacketListEntry **packet_buffer, PacketListEntry **plast_pktl, AVPacket *pkt, @@ -792,6 +793,7 @@ void avpriv_packet_list_free(PacketListEntry **pkt_buf, PacketListEntry **pkt_bu *pkt_buf = NULL; *pkt_buf_end = NULL; } +#endif AVPacketList *av_packet_list_alloc(void) { diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h index 2774d75a7e..fd9637bc44 100644 --- a/libavcodec/packet_internal.h +++ b/libavcodec/packet_internal.h @@ -38,6 +38,7 @@ struct AVPacketList { PacketListEntry *tail; }; +#if LIBAVCODEC_VERSION_MAJOR < 59 /** * Append an AVPacket to the list. * @@ -78,6 +79,7 @@ int avpriv_packet_list_get(PacketListEntry **head, PacketListEntry **tail, * @param tail List tail element */ void avpriv_packet_list_free(PacketListEntry **head, PacketListEntry **tail); +#endif int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); -- 2.29.2 ___ 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] [RFC][PATCH 18/18] avcodec/avpacket: make the AVPacketList API thread safe
Signed-off-by: James Almer --- I don't know if this is necessary, so i'm sending it as an RFC. libavcodec/avpacket.c| 34 +++--- libavcodec/packet_internal.h | 2 ++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 0db47c1d62..a8e934913e 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -807,6 +807,8 @@ AVPacketList *av_packet_list_alloc(void) if (!pktl) return NULL; +ff_mutex_init(&pktl->mutex, NULL); + return (AVPacketList *)pktl; } @@ -840,6 +842,7 @@ int av_packet_list_put(AVPacketList *list, AVPacket *pkt, av_packet_move_ref(&pktle->pkt, pkt); } +ff_mutex_lock(&pktl->mutex); if (pktl->head) pktl->tail->next = pktle; else @@ -847,6 +850,7 @@ int av_packet_list_put(AVPacketList *list, AVPacket *pkt, /* Add the packet in the buffered packet list. */ pktl->tail = pktle; +ff_mutex_unlock(&pktl->mutex); return 0; } @@ -861,8 +865,11 @@ int av_packet_list_get(AVPacketList *list, AVPacket *pkt, AVPacketList *pktl = list; #endif -if (!pktl->head) +ff_mutex_lock(&pktl->mutex); +if (!pktl->head) { +ff_mutex_unlock(&pktl->mutex); return AVERROR(EAGAIN); +} pktle = pktl->head; if (pkt) @@ -873,6 +880,7 @@ int av_packet_list_get(AVPacketList *list, AVPacket *pkt, if (!pktle->next) pktl->tail = NULL; +ff_mutex_unlock(&pktl->mutex); av_freep(&pktle); @@ -891,14 +899,20 @@ int av_packet_list_peek(AVPacketList *list, AVPacket *pkt, AVPacket tmp = { 0 }; int ret; -if (!pktl->head) +ff_mutex_lock(&pktl->mutex); +if (!pktl->head) { +ff_mutex_unlock(&pktl->mutex); return AVERROR(EAGAIN); +} -if (!pkt) +if (!pkt) { + ff_mutex_unlock(&pktl->mutex); return 0; +} pktle = pktl->head; ret = av_packet_ref(&tmp, &pktle->pkt); +ff_mutex_unlock(&pktl->mutex); if (ret < 0) return ret; @@ -915,6 +929,7 @@ void av_packet_list_flush(AVPacketList *list) AVPacketList *pktl = list; #endif +ff_mutex_lock(&pktl->mutex); while (pktl->head) { PacketListEntry *pktle = pktl->head; pktl->head = pktle->next; @@ -923,16 +938,29 @@ void av_packet_list_flush(AVPacketList *list) } pktl->tail = NULL; +ff_mutex_unlock(&pktl->mutex); } void av_packet_list_free(AVPacketList **plist) { AVPacketList *list = *plist; +#if FF_API_PACKET_LIST +struct PacketList *pktl; +#else +AVPacketList *pktl; +#endif if (!list) return; +#if FF_API_PACKET_LIST +pktl = (struct PacketList *)list; +#else +pktl = list; +#endif + av_packet_list_flush(list); +ff_mutex_destroy(&pktl->mutex); av_freep(plist); } diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h index fd9637bc44..4cb3fb4bbd 100644 --- a/libavcodec/packet_internal.h +++ b/libavcodec/packet_internal.h @@ -21,6 +21,7 @@ #include +#include "libavutil/thread.h" #include "packet.h" typedef struct PacketListEntry { @@ -36,6 +37,7 @@ struct AVPacketList { #endif PacketListEntry *head; PacketListEntry *tail; +AVMutex mutex; }; #if LIBAVCODEC_VERSION_MAJOR < 59 -- 2.29.2 ___ 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 08/18] avformat: port AVFormatInternal->parse_queue to the new packet list API
Signed-off-by: James Almer --- libavformat/internal.h | 3 +-- libavformat/options.c | 5 - libavformat/utils.c| 35 --- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index a0649956e8..749e387931 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -89,8 +89,7 @@ struct AVFormatInternal { /** * Packets split by the parser get queued here. */ -struct PacketListEntry *parse_queue; -struct PacketListEntry *parse_queue_end; +struct AVPacketList *parse_queue; /** * Remaining size available for raw_packet_buffer, in bytes. */ diff --git a/libavformat/options.c b/libavformat/options.c index ee7a533aa0..a400419917 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -220,10 +220,13 @@ AVFormatContext *avformat_alloc_context(void) av_free(ic); return NULL; } +internal->parse_queue = av_packet_list_alloc(); internal->packet_buffer = av_packet_list_alloc(); internal->raw_packet_buffer = av_packet_list_alloc(); -if (!internal->packet_buffer || +if (!internal->parse_queue || +!internal->packet_buffer || !internal->raw_packet_buffer) { +av_packet_list_free(&internal->parse_queue); av_packet_list_free(&internal->packet_buffer); av_packet_list_free(&internal->raw_packet_buffer); av_free(internal); diff --git a/libavformat/utils.c b/libavformat/utils.c index 02c0ead44b..59979fb469 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1013,14 +1013,16 @@ static PacketListEntry *get_next_pkt(AVFormatContext *s, AVStream *st, PacketLis { #if FF_API_PACKET_LIST struct PacketList *packet_buffer = (struct PacketList *)s->internal->packet_buffer; +struct PacketList *parse_queue = (struct PacketList *)s->internal->parse_queue; #else AVPacketList *packet_buffer = s->internal->packet_buffer; +AVPacketList *parse_queue = s->internal->parse_queue; #endif if (pktl->next) return pktl->next; if (pktl == packet_buffer->tail) -return s->internal->parse_queue; +return parse_queue->head; return NULL; } @@ -1102,12 +1104,14 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, AVStream *st = s->streams[stream_index]; #if FF_API_PACKET_LIST struct PacketList *packet_buffer = (struct PacketList *)s->internal->packet_buffer; +struct PacketList *parse_queue = (struct PacketList *)s->internal->parse_queue; #else AVPacketList *packet_buffer = s->internal->packet_buffer; +AVPacketList *parse_queue = s->internal->parse_queue; #endif PacketListEntry *pktl = packet_buffer->head ? packet_buffer->head : -s->internal->parse_queue; +parse_queue->head; PacketListEntry *pktl_it; uint64_t shift; @@ -1160,12 +1164,14 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, { #if FF_API_PACKET_LIST struct PacketList *packet_buffer = (struct PacketList *)s->internal->packet_buffer; +struct PacketList *parse_queue = (struct PacketList *)s->internal->parse_queue; #else AVPacketList *packet_buffer = s->internal->packet_buffer; +AVPacketList *parse_queue = s->internal->parse_queue; #endif PacketListEntry *pktl = packet_buffer->head ? packet_buffer->head : -s->internal->parse_queue; +parse_queue->head; int64_t cur_dts= RELATIVE_TS_BASE; if (st->first_dts != AV_NOPTS_VALUE) { @@ -1193,7 +1199,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, } pktl = packet_buffer->head ? packet_buffer->head : -s->internal->parse_queue; +parse_queue->head; st->first_dts = cur_dts; } else if (st->cur_dts != RELATIVE_TS_BASE) return; @@ -1230,8 +1236,10 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, st->codecpar->codec_id != AV_CODEC_ID_HEVC; #if FF_API_PACKET_LIST struct PacketList *packet_buffer = (struct PacketList *)s->internal->packet_buffer; +struct PacketList *parse_queue = (struct PacketList *)s->internal->parse_queue; #else AVPacketList *packet_buffer = s->internal->packet_buffer; +AVPacketList *parse_queue = s->internal->parse_queue; #endif if (s->flags & AVFMT_FLAG_NOFILLIN) @@ -1310,7 +1318,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, } } -if (pkt->duration > 0 && (packet_buffer->head || s->internal->parse_queue)) +if (pkt->duration > 0 && (packet_buffer->head || parse_queue->head)) update_initial_durations(s, st, pkt->stream_index, pkt
[FFmpeg-devel] [PATCH 03/18] avcodec/avpacket: make avpriv_packet_* use PacketListEntry
Signed-off-by: James Almer --- libavcodec/avpacket.c| 18 +- libavcodec/internal.h| 5 +++-- libavcodec/packet_internal.h | 6 +++--- libavformat/aiffenc.c| 4 ++-- libavformat/flacenc.c| 2 +- libavformat/internal.h | 12 ++-- libavformat/matroskadec.c| 4 ++-- libavformat/mp3enc.c | 2 +- libavformat/mux.c| 16 libavformat/mxfenc.c | 12 ++-- libavformat/ttaenc.c | 2 +- libavformat/utils.c | 14 +++--- 12 files changed, 49 insertions(+), 48 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index e4ba403cf6..c12515cf05 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -726,13 +726,13 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif } -int avpriv_packet_list_put(AVPacketList **packet_buffer, - AVPacketList **plast_pktl, +int avpriv_packet_list_put(PacketListEntry **packet_buffer, + PacketListEntry **plast_pktl, AVPacket *pkt, int (*copy)(AVPacket *dst, const AVPacket *src), int flags) { -AVPacketList *pktl = av_mallocz(sizeof(AVPacketList)); +PacketListEntry *pktl = av_mallocz(sizeof(PacketListEntry)); int ret; if (!pktl) @@ -763,11 +763,11 @@ int avpriv_packet_list_put(AVPacketList **packet_buffer, return 0; } -int avpriv_packet_list_get(AVPacketList **pkt_buffer, - AVPacketList **pkt_buffer_end, +int avpriv_packet_list_get(PacketListEntry **pkt_buffer, + PacketListEntry **pkt_buffer_end, AVPacket *pkt) { -AVPacketList *pktl; +PacketListEntry *pktl; if (!*pkt_buffer) return AVERROR(EAGAIN); pktl= *pkt_buffer; @@ -779,12 +779,12 @@ int avpriv_packet_list_get(AVPacketList **pkt_buffer, return 0; } -void avpriv_packet_list_free(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end) +void avpriv_packet_list_free(PacketListEntry **pkt_buf, PacketListEntry **pkt_buf_end) { -AVPacketList *tmp = *pkt_buf; +PacketListEntry *tmp = *pkt_buf; while (tmp) { -AVPacketList *pktl = tmp; +PacketListEntry *pktl = tmp; tmp = pktl->next; av_packet_unref(&pktl->pkt); av_freep(&pktl); diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 17defb9b50..c72cce869e 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -31,6 +31,7 @@ #include "libavutil/mathematics.h" #include "libavutil/pixfmt.h" #include "avcodec.h" +#include "packet_internal.h" #include "config.h" /** @@ -145,8 +146,8 @@ typedef struct AVCodecInternal { * for decoding. */ AVPacket *last_pkt_props; -AVPacketList *pkt_props; -AVPacketList *pkt_props_tail; +PacketListEntry *pkt_props; +PacketListEntry *pkt_props_tail; /** * temporary buffer used for encoders to store their bitstream diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h index 9b9bef94f0..33c9513f16 100644 --- a/libavcodec/packet_internal.h +++ b/libavcodec/packet_internal.h @@ -41,7 +41,7 @@ typedef struct PacketListEntry { * @return 0 on success, negative AVERROR value on failure. On failure, the packet and the list are unchanged. */ -int avpriv_packet_list_put(AVPacketList **head, AVPacketList **tail, +int avpriv_packet_list_put(PacketListEntry **head, PacketListEntry **tail, AVPacket *pkt, int (*copy)(AVPacket *dst, const AVPacket *src), int flags); @@ -58,7 +58,7 @@ int avpriv_packet_list_put(AVPacketList **head, AVPacketList **tail, * @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if * the list was empty. */ -int avpriv_packet_list_get(AVPacketList **head, AVPacketList **tail, +int avpriv_packet_list_get(PacketListEntry **head, PacketListEntry **tail, AVPacket *pkt); /** @@ -67,7 +67,7 @@ int avpriv_packet_list_get(AVPacketList **head, AVPacketList **tail, * @param head List head element * @param tail List tail element */ -void avpriv_packet_list_free(AVPacketList **head, AVPacketList **tail); +void avpriv_packet_list_free(PacketListEntry **head, PacketListEntry **tail); int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index c4ffe9f6d0..7c28109814 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -37,7 +37,7 @@ typedef struct AIFFOutputContext { int64_t frames; int64_t ssnd; int audio_stream_idx; -AVPacketList *pict_list, *pict_list_end; +PacketListEntry *pict_list, *pict_list_end; int write_id3v2; int id3v2_version; } AIFFOu
[FFmpeg-devel] [PATCH 06/18] avformat: port AVFormatInternal->packet_buffer to the new packet list API
Signed-off-by: James Almer --- libavformat/internal.h | 3 +- libavformat/mux.c | 53 +++--- libavformat/mxfenc.c | 19 +++ libavformat/options.c | 6 libavformat/utils.c| 74 ++ 5 files changed, 107 insertions(+), 48 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index d366bdc452..3182409dfb 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -74,8 +74,7 @@ struct AVFormatInternal { * not decoded, for example to get the codec parameters in MPEG * streams. */ -struct PacketListEntry *packet_buffer; -struct PacketListEntry *packet_buffer_end; +struct AVPacketList *packet_buffer; /* av_seek_frame() support */ int64_t data_offset; /**< offset of the first packet */ diff --git a/libavformat/mux.c b/libavformat/mux.c index cf52de5366..6991f81f9f 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -816,6 +816,11 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, PacketListEntry **next_point, *this_pktl; AVStream *st = s->streams[pkt->stream_index]; int chunked = s->max_chunk_size || s->max_chunk_duration; +#if FF_API_PACKET_LIST +struct PacketList *packet_buffer = (struct PacketList *)s->internal->packet_buffer; +#else +AVPacketList *packet_buffer = s->internal->packet_buffer; +#endif this_pktl= av_malloc(sizeof(PacketListEntry)); if (!this_pktl) { @@ -834,7 +839,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, if (st->internal->last_in_packet_buffer) { next_point = &(st->internal->last_in_packet_buffer->next); } else { -next_point = &s->internal->packet_buffer; +next_point = &packet_buffer->head; } if (chunked) { @@ -858,7 +863,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, if (chunked && !(pkt->flags & CHUNK_START)) goto next_non_null; -if (compare(s, &s->internal->packet_buffer_end->pkt, pkt)) { +if (compare(s, &packet_buffer->tail->pkt, pkt)) { while ( *next_point && ((chunked && !((*next_point)->pkt.flags&CHUNK_START)) || !compare(s, &(*next_point)->pkt, pkt))) @@ -866,12 +871,12 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, if (*next_point) goto next_non_null; } else { -next_point = &(s->internal->packet_buffer_end->next); +next_point = &(packet_buffer->tail->next); } } av_assert1(!*next_point); -s->internal->packet_buffer_end = this_pktl; +packet_buffer->tail = this_pktl; next_non_null: this_pktl->next = *next_point; @@ -920,6 +925,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, int noninterleaved_count = 0; int i, ret; int eof = flush; +#if FF_API_PACKET_LIST +struct PacketList *packet_buffer = (struct PacketList *)s->internal->packet_buffer; +#else +AVPacketList *packet_buffer = s->internal->packet_buffer; +#endif if (pkt) { if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0) @@ -940,11 +950,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, flush = 1; if (s->max_interleave_delta > 0 && -s->internal->packet_buffer && +packet_buffer->head && !flush && s->internal->nb_interleaved_streams == stream_count+noninterleaved_count ) { -AVPacket *top_pkt = &s->internal->packet_buffer->pkt; +AVPacket *top_pkt = &packet_buffer->head->pkt; int64_t delta_dts = INT64_MIN; int64_t top_dts = av_rescale_q(top_pkt->dts, s->streams[top_pkt->stream_index]->time_base, @@ -972,11 +982,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, } } -if (s->internal->packet_buffer && +if (packet_buffer->head && eof && (s->flags & AVFMT_FLAG_SHORTEST) && s->internal->shortest_end == AV_NOPTS_VALUE) { -AVPacket *top_pkt = &s->internal->packet_buffer->pkt; +AVPacket *top_pkt = &packet_buffer->head->pkt; s->internal->shortest_end = av_rescale_q(top_pkt->dts, s->streams[top_pkt->stream_index]->time_base, @@ -984,8 +994,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, } if (s->internal->shortest_end != AV_NOPTS_VALUE) { -while (s->internal->packet_buffer) { -AVPacket *top_pkt = &s->internal->packet_buffer->pkt; +while (packet_buffer->head) { +AVPacket *top_pkt = &packet_buffer->head->pkt; AVStream *st; int64_t top_dts = av_rescale_q(top_pkt->dts, s->streams[top_pkt->stream_in
[FFmpeg-devel] [PATCH 07/18] avformat: port AVFormatInternal->raw_packet_buffer to the new packet list API
Signed-off-by: James Almer --- libavformat/internal.h | 3 +-- libavformat/options.c | 6 +- libavformat/utils.c| 21 - 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 3182409dfb..a0649956e8 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -85,8 +85,7 @@ struct AVFormatInternal { * be identified, as parsing cannot be done without knowing the * codec. */ -struct PacketListEntry *raw_packet_buffer; -struct PacketListEntry *raw_packet_buffer_end; +struct AVPacketList *raw_packet_buffer; /** * Packets split by the parser get queued here. */ diff --git a/libavformat/options.c b/libavformat/options.c index 9fe1500cee..ee7a533aa0 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -221,7 +221,11 @@ AVFormatContext *avformat_alloc_context(void) return NULL; } internal->packet_buffer = av_packet_list_alloc(); -if (!internal->packet_buffer) { +internal->raw_packet_buffer = av_packet_list_alloc(); +if (!internal->packet_buffer || +!internal->raw_packet_buffer) { +av_packet_list_free(&internal->packet_buffer); +av_packet_list_free(&internal->raw_packet_buffer); av_free(internal); av_free(ic); return NULL; diff --git a/libavformat/utils.c b/libavformat/utils.c index 88ce64496d..02c0ead44b 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -452,8 +452,7 @@ int avformat_queue_attached_pictures(AVFormatContext *s) continue; } -ret = avpriv_packet_list_put(&s->internal->raw_packet_buffer, - &s->internal->raw_packet_buffer_end, +ret = av_packet_list_put(s->internal->raw_packet_buffer, &s->streams[i]->attached_pic, av_packet_ref, 0); if (ret < 0) @@ -793,13 +792,18 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, i, err; AVStream *st; +#if FF_API_PACKET_LIST +struct PacketList *raw_packet_buffer = (struct PacketList *)s->internal->raw_packet_buffer; +#else +AVPacketList *raw_packet_buffer = s->internal->raw_packet_buffer; +#endif pkt->data = NULL; pkt->size = 0; av_init_packet(pkt); for (;;) { -PacketListEntry *pktl = s->internal->raw_packet_buffer; +PacketListEntry *pktl = raw_packet_buffer->head; const AVPacket *pkt1; if (pktl) { @@ -808,8 +812,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) if ((err = probe_codec(s, st, NULL)) < 0) return err; if (st->internal->request_probe <= 0) { -avpriv_packet_list_get(&s->internal->raw_packet_buffer, - &s->internal->raw_packet_buffer_end, pkt); +av_packet_list_get(s->internal->raw_packet_buffer, pkt, 0); s->internal->raw_packet_buffer_remaining_size += pkt->size; return 0; } @@ -881,14 +884,13 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) if (!pktl && st->internal->request_probe <= 0) return ret; -err = avpriv_packet_list_put(&s->internal->raw_packet_buffer, - &s->internal->raw_packet_buffer_end, +err = av_packet_list_put(s->internal->raw_packet_buffer, pkt, NULL, 0); if (err < 0) { av_packet_unref(pkt); return err; } -pkt1 = &s->internal->raw_packet_buffer_end->pkt; +pkt1 = &raw_packet_buffer->tail->pkt; s->internal->raw_packet_buffer_remaining_size -= pkt1->size; if ((err = probe_codec(s, st, pkt1)) < 0) @@ -1843,7 +1845,7 @@ static void flush_packet_queue(AVFormatContext *s) return; avpriv_packet_list_free(&s->internal->parse_queue, &s->internal->parse_queue_end); av_packet_list_flush(s->internal->packet_buffer); -avpriv_packet_list_free(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end); +av_packet_list_flush(s->internal->raw_packet_buffer); s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; } @@ -4471,6 +4473,7 @@ void avformat_free_context(AVFormatContext *s) av_freep(&s->streams); flush_packet_queue(s); av_packet_list_free(&s->internal->packet_buffer); +av_packet_list_free(&s->internal->raw_packet_buffer); av_freep(&s->internal); av_freep(&s->url); av_free(s); -- 2.29.2 ___ 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 10/18] avdevice/decklink_dec: port to the new packet list API
Signed-off-by: James Almer --- libavdevice/decklink_common.h | 2 +- libavdevice/decklink_dec.cpp | 53 +-- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index f35bd9ae6f..9ee877f349 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -75,7 +75,7 @@ class decklink_output_callback; class decklink_input_callback; typedef struct AVPacketQueue { -AVPacketList *first_pkt, *last_pkt; +AVPacketList *pktl; int nb_packets; unsigned long long size; int abort_request; diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 6517b9df13..1115c5af79 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -469,10 +469,13 @@ skip_packet: return tgt; } -static void avpacket_queue_init(AVFormatContext *avctx, AVPacketQueue *q) +static int avpacket_queue_init(AVFormatContext *avctx, AVPacketQueue *q) { struct decklink_cctx *ctx = (struct decklink_cctx *)avctx->priv_data; memset(q, 0, sizeof(AVPacketQueue)); +q->pktl = av_packet_list_alloc(); +if (!q->pktl) +return AVERROR(ENOMEM); pthread_mutex_init(&q->mutex, NULL); pthread_cond_init(&q->cond, NULL); q->avctx = avctx; @@ -484,13 +487,7 @@ static void avpacket_queue_flush(AVPacketQueue *q) AVPacketList *pkt, *pkt1; pthread_mutex_lock(&q->mutex); -for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { -pkt1 = pkt->next; -av_packet_unref(&pkt->pkt); -av_freep(&pkt); -} -q->last_pkt = NULL; -q->first_pkt = NULL; +av_packet_list_flush(q->pktl); q->nb_packets = 0; q->size = 0; pthread_mutex_unlock(&q->mutex); @@ -499,6 +496,7 @@ static void avpacket_queue_flush(AVPacketQueue *q) static void avpacket_queue_end(AVPacketQueue *q) { avpacket_queue_flush(q); +av_packet_list_free(&q->pktl); pthread_mutex_destroy(&q->mutex); pthread_cond_destroy(&q->cond); } @@ -514,7 +512,7 @@ static unsigned long long avpacket_queue_size(AVPacketQueue *q) static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) { -AVPacketList *pkt1; +int size; // Drop Packet if queue size is > maximum queue size if (avpacket_queue_size(q) > (uint64_t)q->max_q_size) { @@ -528,25 +526,16 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) return -1; } -pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList)); -if (!pkt1) { -av_packet_unref(pkt); -return -1; -} -av_packet_move_ref(&pkt1->pkt, pkt); -pkt1->next = NULL; - pthread_mutex_lock(&q->mutex); -if (!q->last_pkt) { -q->first_pkt = pkt1; -} else { -q->last_pkt->next = pkt1; -} +size = pkt->size; + +ret = av_packet_list_put(q->pktl, pkt, 0); +if (ret < 0) +return 0; -q->last_pkt = pkt1; q->nb_packets++; -q->size += pkt1->pkt.size + sizeof(*pkt1); +q->size += size; pthread_cond_signal(&q->cond); @@ -562,16 +551,10 @@ static int avpacket_queue_get(AVPacketQueue *q, AVPacket *pkt, int block) pthread_mutex_lock(&q->mutex); for (;; ) { -pkt1 = q->first_pkt; -if (pkt1) { -q->first_pkt = pkt1->next; -if (!q->first_pkt) { -q->last_pkt = NULL; -} +ret = av_packet_list_get(q->pktl, pkt, 0); +if (!ret) { q->nb_packets--; -q->size -= pkt1->pkt.size + sizeof(*pkt1); -*pkt = pkt1->pkt; -av_free(pkt1); +q->size -= pkt.size; ret = 1; break; } else if (!block) { @@ -1382,7 +1365,9 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) goto error; } -avpacket_queue_init (avctx, &ctx->queue); +ret = avpacket_queue_init(avctx, &ctx->queue); +if (ret < 0) +goto error; if (ctx->dli->StartStreams() != S_OK) { av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n"); -- 2.29.2 ___ 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 00/18] AVPacketList public API
This is an attempt at introducing a public packet list API, after the need for it outside of libavformat became evident. It reuses the existing AVPacketList struct by making it opaque, so we can have a head and tail pointers internally instead of having to expose them in a very awkward way in the functions, like it's currently the case with the private packet list functions. Since AVPacketList is already a public struct, the only way to reuse it was by deprecating all of its fields and scheduling making it opaque in a soname bump >= 2 years from now. James Almer (18): avcodec/packet_internal: add a PacketListEntry struct avformat/internal: make last_in_packet_buffer of type PacketListEntry avcodec/avpacket: make avpriv_packet_* use PacketListEntry avcodec/avpacket: add a new public AVPacketList API avcodec/decode: port to the new packet list API avformat: port AVFormatInternal->packet_buffer to the new packet list API avformat: port AVFormatInternal->raw_packet_buffer to the new packet list API avformat: port AVFormatInternal->parse_queue to the new packet list API avdevice/dshow: port to the new packet list API avdevice/decklink_dec: port to the new packet list API avdevice/vfwcap: port to the new packet list API avformat/ttaenc: port to the new packet list API avformat/mp3enc: port to the new packet list API avformat/flacenc: port to the new packet list API avformat/aiffenc: port to the new packet list API avformat/matroskadec: port to the new packet list API avcodec/avpacket: schedule the removal of avpriv_packet_list_* avcodec/avpacket: make the AVPacketList API thread safe libavcodec/avpacket.c | 189 -- libavcodec/decode.c | 20 ++-- libavcodec/internal.h | 1 - libavcodec/packet.h | 88 +++- libavcodec/packet_internal.h | 24 - libavcodec/utils.c| 11 +- libavcodec/version.h | 3 + libavdevice/decklink_common.h | 2 +- libavdevice/decklink_dec.cpp | 53 -- libavdevice/dshow.c | 52 +- libavdevice/vfwcap.c | 49 - libavformat/aiffenc.c | 22 ++-- libavformat/flacenc.c | 13 ++- libavformat/internal.h| 6 +- libavformat/matroskadec.c | 29 +++--- libavformat/mp3enc.c | 13 ++- libavformat/mux.c | 64 +++- libavformat/mxfenc.c | 23 +++-- libavformat/options.c | 13 +++ libavformat/ttaenc.c | 14 +-- libavformat/utils.c | 128 --- 21 files changed, 583 insertions(+), 234 deletions(-) -- 2.29.2 ___ 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 01/18] avcodec/packet_internal: add a PacketListEntry struct
This will functionally replace AVPacketList as it currently stands, and is the first step in preparation for a new public AVPacketList API Signed-off-by: James Almer --- libavcodec/packet_internal.h | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h index 832ddb4a61..9b9bef94f0 100644 --- a/libavcodec/packet_internal.h +++ b/libavcodec/packet_internal.h @@ -23,6 +23,10 @@ #include "packet.h" +typedef struct PacketListEntry { +AVPacket pkt; +struct PacketListEntry *next; +} PacketListEntry; /** * Append an AVPacket to the list. -- 2.29.2 ___ 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 04/18] avcodec/avpacket: add a new public AVPacketList API
This implements a FIFO packet buffering API. All existing fields in the AVPacketList struct are deprecated, and will be removed eventually. After that, AVPacketList will become an opaque struct. Signed-off-by: James Almer --- The most important thing is getting the function signatures right. The internal implementation can always be changed since AVPacketList will not be publicly exposed. I've allowed the pkt parameter in av_packet_list_peek() to be NULL, in which case the function will behave like an is_empty() function of sorts. I've also added a flags parameter to put(), get() and peek() for future extensions. For example, we may want to make them append a packet at the beginning of the list, and return the one at the end. libavcodec/avpacket.c| 141 +++ libavcodec/packet.h | 88 +- libavcodec/packet_internal.h | 10 +++ libavcodec/version.h | 3 + 4 files changed, 240 insertions(+), 2 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index c12515cf05..c79200b63b 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -793,6 +793,147 @@ void avpriv_packet_list_free(PacketListEntry **pkt_buf, PacketListEntry **pkt_bu *pkt_buf_end = NULL; } +AVPacketList *av_packet_list_alloc(void) +{ +#if FF_API_PACKET_LIST +struct PacketList *pktl; +#else +AVPacketList *pktl; +#endif +pktl = av_mallocz(sizeof(*pktl)); + +if (!pktl) +return NULL; + +return (AVPacketList *)pktl; +} + +int av_packet_list_put(AVPacketList *list, AVPacket *pkt, + int (*copy)(AVPacket *dst, const AVPacket *src), + int flags) +{ +PacketListEntry *pktle = av_mallocz(sizeof(PacketListEntry)); +#if FF_API_PACKET_LIST +struct PacketList *pktl = (struct PacketList *)list; +#else +AVPacketList *pktl = list; +#endif +int ret; + +if (!pktle) +return AVERROR(ENOMEM); + +if (copy) { +ret = copy(&pktle->pkt, pkt); +if (ret < 0) { +av_free(pktle); +return ret; +} +} else { +ret = av_packet_make_refcounted(pkt); +if (ret < 0) { +av_free(pktle); +return ret; +} +av_packet_move_ref(&pktle->pkt, pkt); +} + +if (pktl->head) +pktl->tail->next = pktle; +else +pktl->head = pktle; + +/* Add the packet in the buffered packet list. */ +pktl->tail = pktle; + +return 0; +} + +int av_packet_list_get(AVPacketList *list, AVPacket *pkt, + int flags) +{ +PacketListEntry *pktle; +#if FF_API_PACKET_LIST +struct PacketList *pktl = (struct PacketList *)list; +#else +AVPacketList *pktl = list; +#endif + +if (!pktl->head) +return AVERROR(EAGAIN); + +pktle = pktl->head; +if (pkt) +*pkt = pktle->pkt; +else +av_packet_unref(&pktle->pkt); +pktl->head = pktle->next; + +if (!pktle->next) +pktl->tail = NULL; + +av_freep(&pktle); + +return 0; +} + +int av_packet_list_peek(AVPacketList *list, AVPacket *pkt, +int flags) +{ +PacketListEntry *pktle; +#if FF_API_PACKET_LIST +struct PacketList *pktl = (struct PacketList *)list; +#else +AVPacketList *pktl = list; +#endif +AVPacket tmp = { 0 }; +int ret; + +if (!pktl->head) +return AVERROR(EAGAIN); + +if (!pkt) + return 0; + +pktle = pktl->head; +ret = av_packet_ref(&tmp, &pktle->pkt); +if (ret < 0) +return ret; + +*pkt = tmp; + +return 0; +} + +void av_packet_list_flush(AVPacketList *list) +{ +#if FF_API_PACKET_LIST +struct PacketList *pktl = (struct PacketList *)list; +#else +AVPacketList *pktl = list; +#endif + +while (pktl->head) { +PacketListEntry *pktle = pktl->head; +pktl->head = pktle->next; +av_packet_unref(&pktle->pkt); +av_freep(&pktle); +} + +pktl->tail = NULL; +} + +void av_packet_list_free(AVPacketList **plist) +{ +AVPacketList *list = *plist; + +if (!list) +return; + +av_packet_list_flush(list); +av_freep(plist); +} + int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) { uint8_t *side_data; diff --git a/libavcodec/packet.h b/libavcodec/packet.h index b9d4c9c2c8..d3c8ba40b5 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -393,10 +393,94 @@ typedef struct AVPacket { #endif } AVPacket; -typedef struct AVPacketList { +typedef struct AVPacketList +#if FF_API_PACKET_LIST +{ +/** + * @deprecated This field is unused + */ +attribute_deprecated AVPacket pkt; +/** + * @deprecated This field is unused + */ +attribute_deprecated struct AVPacketList *next; -} AVPacketList; +} +#endif +AVPacketList; + +/** + * Allocate an AVPacketList struct. + * + * @note The allocated struc
[FFmpeg-devel] [PATCH 14/18] avformat/flacenc: port to the new packet list API
Signed-off-by: James Almer --- libavformat/flacenc.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index a24d3be85d..6fb5e59be0 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -39,7 +39,7 @@ typedef struct FlacMuxerContext { int audio_stream_idx; int waiting_pics; /* audio packets are queued here until we get all the attached pictures */ -PacketListEntry *queue, *queue_end; +AVPacketList *queue; /* updated streaminfo sent by the encoder at the end */ uint8_t streaminfo[FLAC_STREAMINFO_SIZE]; @@ -253,6 +253,10 @@ static int flac_init(struct AVFormatContext *s) } } +c->queue = av_packet_list_alloc(); +if (!c->queue) +return AVERROR(ENOMEM); + return 0; } @@ -305,8 +309,7 @@ static int flac_queue_flush(AVFormatContext *s) if (ret < 0) write = 0; -while (c->queue) { -avpriv_packet_list_get(&c->queue, &c->queue_end, &pkt); +while (av_packet_list_get(c->queue, &pkt, 0)) { if (write && (ret = flac_write_audio_packet(s, &pkt)) < 0) write = 0; av_packet_unref(&pkt); @@ -346,7 +349,7 @@ static void flac_deinit(struct AVFormatContext *s) { FlacMuxerContext *c = s->priv_data; -avpriv_packet_list_free(&c->queue, &c->queue_end); +av_packet_list_free(&c->queue); } static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt) @@ -357,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt) if (pkt->stream_index == c->audio_stream_idx) { if (c->waiting_pics) { /* buffer audio packets until we get all the pictures */ -ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, av_packet_ref, 0); +ret = av_packet_list_put(c->queue, pkt, av_packet_ref, 0); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n"); c->waiting_pics = 0; -- 2.29.2 ___ 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 02/18] avformat/internal: make last_in_packet_buffer of type PacketListEntry
Signed-off-by: James Almer --- libavformat/internal.h | 3 ++- libavformat/mux.c | 11 ++- libavformat/mxfenc.c | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 49e82bfbca..c29c7deec7 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -26,6 +26,7 @@ #include "libavutil/bprint.h" #include "avformat.h" #include "os_support.h" +#include "libavcodec/packet_internal.h" #define MAX_URL_SIZE 4096 @@ -342,7 +343,7 @@ struct AVStreamInternal { /** * last packet in packet_buffer for this stream when muxing. */ -struct AVPacketList *last_in_packet_buffer; +struct PacketListEntry *last_in_packet_buffer; }; #ifdef __GNUC__ diff --git a/libavformat/mux.c b/libavformat/mux.c index d2a56d216b..d60bf2218b 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -832,7 +832,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, pkt = &this_pktl->pkt; if (st->internal->last_in_packet_buffer) { -next_point = &(st->internal->last_in_packet_buffer->next); +next_point = (AVPacketList **)&(st->internal->last_in_packet_buffer->next); } else { next_point = &s->internal->packet_buffer; } @@ -876,7 +876,8 @@ next_non_null: this_pktl->next = *next_point; -st->internal->last_in_packet_buffer = *next_point = this_pktl; +*next_point = this_pktl; +st->internal->last_in_packet_buffer = (PacketListEntry *)this_pktl; return 0; } @@ -951,7 +952,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, for (i = 0; i < s->nb_streams; i++) { int64_t last_dts; -const AVPacketList *last = s->streams[i]->internal->last_in_packet_buffer; +const PacketListEntry *last = s->streams[i]->internal->last_in_packet_buffer; if (!last) continue; @@ -1000,7 +1001,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, if (!s->internal->packet_buffer) s->internal->packet_buffer_end = NULL; -if (st->internal->last_in_packet_buffer == pktl) +if (st->internal->last_in_packet_buffer == (PacketListEntry *)pktl) st->internal->last_in_packet_buffer = NULL; av_packet_unref(&pktl->pkt); @@ -1019,7 +1020,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, if (!s->internal->packet_buffer) s->internal->packet_buffer_end = NULL; -if (st->internal->last_in_packet_buffer == pktl) +if (st->internal->last_in_packet_buffer == (PacketListEntry *)pktl) st->internal->last_in_packet_buffer = NULL; av_freep(&pktl); diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index d8678c9d25..c7f98ac257 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -3061,8 +3061,8 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket if (!stream_count || pktl->pkt.stream_index == 0) break; // update last packet in packet buffer -if (s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer != pktl) - s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer = pktl; +if (s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer != (PacketListEntry *)pktl) + s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer = (PacketListEntry *)pktl; last = pktl; pktl = pktl->next; stream_count--; @@ -3087,7 +3087,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket *out = pktl->pkt; av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts); s->internal->packet_buffer = pktl->next; -if(s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer == pktl) +if(s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer == (PacketListEntry *)pktl) s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer= NULL; if(!s->internal->packet_buffer) s->internal->packet_buffer_end= NULL; -- 2.29.2 ___ 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] libavformat/mov.c: export vendor id as metadata
On Wed, Nov 18, 2020 at 12:30 AM Gyan Doshi wrote: > > > On 18-11-2020 12:16 pm, Thierry Foucu wrote: > > On Tue, Nov 17, 2020 at 9:54 PM Gyan Doshi wrote: > > > >> > >> On 18-11-2020 02:41 am, Thierry Foucu wrote: > >>> --- > >>>libavformat/mov.c | 24 ++-- > >>>1 file changed, 22 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/libavformat/mov.c b/libavformat/mov.c > >>> index 2b90e31170..1f9163d658 100644 > >>> --- a/libavformat/mov.c > >>> +++ b/libavformat/mov.c > >>> @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, > >> AVIOContext *pb, > >>>uint8_t codec_name[32] = { 0 }; > >>>int64_t stsd_start; > >>>unsigned int len; > >>> +int32_t id = 0; > >>> +char vendor_id[5]; > >>> > >>>/* The first 16 bytes of the video sample description are > already > >>> * read in ff_mov_read_stsd_entries() */ > >>> @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, > >> AVIOContext *pb, > >>>avio_rb16(pb); /* version */ > >>>avio_rb16(pb); /* revision level */ > >>> -avio_rb32(pb); /* vendor */ > >>> +id = avio_rb32(pb); /* vendor */ > >>> +if (id != 0) { > >>> +vendor_id[0] = (id >> 24) & 0xff; > >>> +vendor_id[1] = (id >> 16) & 0xff; > >>> +vendor_id[2] = (id >> 8) & 0xff; > >>> +vendor_id[3] = (id >> 0) & 0xff; > >>> +vendor_id[4] = 0; > >>> +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); > >>> +} > >>>avio_rb32(pb); /* temporal quality */ > >>>avio_rb32(pb); /* spatial quality */ > >>> > >>> @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, > >> AVIOContext *pb, > >>>{ > >>>int bits_per_sample, flags; > >>>uint16_t version = avio_rb16(pb); > >>> +int32_t id = 0; > >>> +char vendor_id[5]; > >>>AVDictionaryEntry *compatible_brands = > >> av_dict_get(c->fc->metadata, "compatible_brands", NULL, > AV_DICT_MATCH_CASE); > >>>avio_rb16(pb); /* revision level */ > >>> -avio_rb32(pb); /* vendor */ > >>> +id = avio_rb32(pb); /* vendor */ > >>> +if (id != 0) { > >>> +vendor_id[0] = (id >> 24) & 0xff; > >>> +vendor_id[1] = (id >> 16) & 0xff; > >>> +vendor_id[2] = (id >> 8) & 0xff; > >>> +vendor_id[3] = (id >> 0) & 0xff; > >>> +vendor_id[4] = 0; > >>> +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); > >>> +} > >> Seems fine. > >> > >> But you likely have to update many FATE refs. FATE fails. See > >> https://patchwork.ffmpeg.org/check/20508/ > >> This automated check stops with the first failure. So check for all > >> tests with '-k' > >> > > Thanks. > > I did look at the error but it does not seem related to this patch. > > Looking at it, i'm not sure how adding vendor ID could break a RGB24 in > > matroska. > > The test demuxes a MOV and transcodes streams to MKV. Since your patch > adds a metadata entry, that changes the metadata written to the output. > > Ah.. I see.. Will be sending new patch soon with fate tests fixed > Gyan > ___ > 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". -- Thierry Foucu ___ 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] libavformat/mov.c: export vendor id as metadata
--- libavformat/mov.c | 24 +-- ...hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 + .../fate/hapqa-extract-nosnappy-to-hapq-mov | 1 + tests/ref/fate/mov-zombie | 2 +- tests/ref/fate/rgb24-mkv | 4 ++-- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2b90e31170..1f9163d658 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, uint8_t codec_name[32] = { 0 }; int64_t stsd_start; unsigned int len; +int32_t id = 0; +char vendor_id[5]; /* The first 16 bytes of the video sample description are already * read in ff_mov_read_stsd_entries() */ @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, avio_rb16(pb); /* version */ avio_rb16(pb); /* revision level */ -avio_rb32(pb); /* vendor */ +id = avio_rb32(pb); /* vendor */ +if (id != 0) { +vendor_id[0] = (id >> 24) & 0xff; +vendor_id[1] = (id >> 16) & 0xff; +vendor_id[2] = (id >> 8) & 0xff; +vendor_id[3] = (id >> 0) & 0xff; +vendor_id[4] = 0; +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); +} avio_rb32(pb); /* temporal quality */ avio_rb32(pb); /* spatial quality */ @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, { int bits_per_sample, flags; uint16_t version = avio_rb16(pb); +int32_t id = 0; +char vendor_id[5]; AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); avio_rb16(pb); /* revision level */ -avio_rb32(pb); /* vendor */ +id = avio_rb32(pb); /* vendor */ +if (id != 0) { +vendor_id[0] = (id >> 24) & 0xff; +vendor_id[1] = (id >> 16) & 0xff; +vendor_id[2] = (id >> 8) & 0xff; +vendor_id[3] = (id >> 0) & 0xff; +vendor_id[4] = 0; +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); +} st->codecpar->channels = avio_rb16(pb); /* channel count */ st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* sample size */ diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov index 61af08aa23..04a965b12a 100644 --- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov +++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov @@ -69,5 +69,6 @@ DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:language=eng TAG:handler_name=Module de gestion video +TAG:vendor_id=FFMP TAG:encoder=HAPAlpha Only [/STREAM] diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov index 1fb31ec7f0..d9e5c94ffb 100644 --- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov +++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov @@ -69,5 +69,6 @@ DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:language=eng TAG:handler_name=Module de gestion video +TAG:vendor_id=FFMP TAG:encoder=HAPQ [/STREAM] diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie index 1a6625bc8f..c566b14d47 100644 --- a/tests/ref/fate/mov-zombie +++ b/tests/ref/fate/mov-zombie @@ -194,5 +194,5 @@ frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=188623|pkt_pts_time=2. packet|codec_type=video|stream_index=0|pts=197632|pts_time=2.195911|dts=191625|dts_time=2.129167|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=580|pos=101820|flags=__ frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=191626|pkt_pts_time=2.129178|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=191626|best_effort_timestamp_time=2.129178|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=99180|pkt_size=1666|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=63|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message -stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_time_base=212521/12744000|codec_tag_string=avc1|codec_tag=0x31637661|width=160|height=240|coded_width=160|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=2:1|display_aspect_ratio=4:3|pix_fmt=yuv420p|level=12|color_range=tv|color_space=smpte170m|color_transfer=bt709|color_primaries=smpte170m|chroma_location=topleft|field_order=unknown|timecode=N/A|refs=2|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=3/1001|avg_frame_rate=6372000/212521|time_base=1/9|start_pts=0|start_time=0.00|duration_ts=2125200|duration=23.61|bit_rate=33
Re: [FFmpeg-devel] [PATCH v2] avdevice/decklink_dec: map the raw_format instead of hardcode
On Sat, 14 Nov 2020, lance.lmw...@gmail.com wrote: From: Limin Wang Well, this patch changes the numerical values for the string constants. We sometimes do that, and probably it is cleaner if we do mapping the same way we do with other options, but a libavdevice micro bump is definitely needed for the change. Signed-off-by: Limin Wang --- libavdevice/decklink_common.h | 9 + libavdevice/decklink_dec.cpp | 3 ++- libavdevice/decklink_dec_c.c | 12 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index f35bd9a..ac15488 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -162,6 +162,15 @@ IDeckLinkIterator *CreateDeckLinkIteratorInstance(void); typedef uint32_t buffercount_type; #endif +static const BMDPixelFormat decklink_raw_format_map[] = { +BMDPixelFormat(0), Please follow the C syntax: (BMDPixelFormat)0 +bmdFormat8BitYUV, +bmdFormat10BitYUV, +bmdFormat8BitARGB, +bmdFormat8BitBGRA, +bmdFormat10BitRGB, +}; + static const BMDAudioConnection decklink_audio_connection_map[] = { (BMDAudioConnection)0, bmdAudioConnectionEmbedded, diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 6517b9d..049e133 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -1152,7 +1152,8 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) ctx->video_pts_source = cctx->video_pts_source; ctx->draw_bars = cctx->draw_bars; ctx->audio_depth = cctx->audio_depth; -ctx->raw_format = (BMDPixelFormat)cctx->raw_format; +if (cctx->raw_format > 0 && (unsigned int)cctx->raw_format < FF_ARRAY_ELEMS(decklink_raw_format_map)) +ctx->raw_format = decklink_raw_format_map[cctx->raw_format]; cctx->ctx = ctx; /* Check audio channel option for valid values: 2, 8 or 16 */ diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c index f3fdcd3..66786db 100644 --- a/libavdevice/decklink_dec_c.c +++ b/libavdevice/decklink_dec_c.c @@ -34,12 +34,12 @@ static const AVOption options[] = { { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, { "format_code", "set format by fourcc", OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC }, { "raw_format", "pixel format to be returned by the card when capturing" , OFFSET(raw_format), AV_OPT_TYPE_INT, { .i64 = 0}, 0, UINT_MAX, DEC, "raw_format" }, The maximum should also be updated. -{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, DEC, "raw_format"}, -{ "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('2','v','u','y') }, 0, 0, DEC, "raw_format"}, -{ "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('v','2','1','0') }, 0, 0, DEC, "raw_format"}, -{ "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 32 }, 0, 0, DEC, "raw_format"}, -{ "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('B','G','R','A') }, 0, 0, DEC, "raw_format"}, -{ "rgb10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('r','2','1','0') }, 0, 0, DEC, "raw_format"}, +{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, DEC, "raw_format"}, +{ "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, DEC, "raw_format"}, +{ "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, DEC, "raw_format"}, +{ "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, 0, 0, DEC, "raw_format"}, +{ "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, 0, 0, DEC, "raw_format"}, +{ "rgb10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 5 }, 0, 0, DEC, "raw_format"}, { "enable_klv","output klv if present in vanc", OFFSET(enable_klv), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC }, { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7LL, DEC, "teletext_lines"}, { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0,DEC, "teletext_lines"}, Regards, 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] libavformat/mov.c: export vendor id as metadata
Thierry Foucu: > --- > libavformat/mov.c | 24 +-- > ...hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 + > .../fate/hapqa-extract-nosnappy-to-hapq-mov | 1 + > tests/ref/fate/mov-zombie | 2 +- > tests/ref/fate/rgb24-mkv | 4 ++-- > 5 files changed, 27 insertions(+), 5 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 2b90e31170..1f9163d658 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, > AVIOContext *pb, > uint8_t codec_name[32] = { 0 }; > int64_t stsd_start; > unsigned int len; > +int32_t id = 0; > +char vendor_id[5]; > > /* The first 16 bytes of the video sample description are already > * read in ff_mov_read_stsd_entries() */ > @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, > AVIOContext *pb, > > avio_rb16(pb); /* version */ > avio_rb16(pb); /* revision level */ > -avio_rb32(pb); /* vendor */ > +id = avio_rb32(pb); /* vendor */ > +if (id != 0) { > +vendor_id[0] = (id >> 24) & 0xff; > +vendor_id[1] = (id >> 16) & 0xff; > +vendor_id[2] = (id >> 8) & 0xff; > +vendor_id[3] = (id >> 0) & 0xff; > +vendor_id[4] = 0; > +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); > +} > avio_rb32(pb); /* temporal quality */ > avio_rb32(pb); /* spatial quality */ > > @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, > AVIOContext *pb, > { > int bits_per_sample, flags; > uint16_t version = avio_rb16(pb); > +int32_t id = 0; > +char vendor_id[5]; > AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, > "compatible_brands", NULL, AV_DICT_MATCH_CASE); > > avio_rb16(pb); /* revision level */ > -avio_rb32(pb); /* vendor */ > +id = avio_rb32(pb); /* vendor */ > +if (id != 0) { > +vendor_id[0] = (id >> 24) & 0xff; > +vendor_id[1] = (id >> 16) & 0xff; > +vendor_id[2] = (id >> 8) & 0xff; > +vendor_id[3] = (id >> 0) & 0xff; AV_WB32(). Alternatively, one could use av_fourcc2str() if you like its handling of characters outside the [A-Za-z0-9._ -] set (but for this you would need to read the number via avio_rl32()). - Andreas ___ 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] [RFC][PATCH 18/18] avcodec/avpacket: make the AVPacketList API thread safe
On Wed, 18 Nov 2020, James Almer wrote: Signed-off-by: James Almer --- I don't know if this is necessary, so i'm sending it as an RFC. I don't think this API should provide locking by default, maybe as an option. But considering that it was not often needed so far, and the API can be wrapped into locked versions (like decklink does) relatively easily, I think it is fine as is. Regards, Marton libavcodec/avpacket.c| 34 +++--- libavcodec/packet_internal.h | 2 ++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 0db47c1d62..a8e934913e 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -807,6 +807,8 @@ AVPacketList *av_packet_list_alloc(void) if (!pktl) return NULL; +ff_mutex_init(&pktl->mutex, NULL); + return (AVPacketList *)pktl; } @@ -840,6 +842,7 @@ int av_packet_list_put(AVPacketList *list, AVPacket *pkt, av_packet_move_ref(&pktle->pkt, pkt); } +ff_mutex_lock(&pktl->mutex); if (pktl->head) pktl->tail->next = pktle; else @@ -847,6 +850,7 @@ int av_packet_list_put(AVPacketList *list, AVPacket *pkt, /* Add the packet in the buffered packet list. */ pktl->tail = pktle; +ff_mutex_unlock(&pktl->mutex); return 0; } @@ -861,8 +865,11 @@ int av_packet_list_get(AVPacketList *list, AVPacket *pkt, AVPacketList *pktl = list; #endif -if (!pktl->head) +ff_mutex_lock(&pktl->mutex); +if (!pktl->head) { +ff_mutex_unlock(&pktl->mutex); return AVERROR(EAGAIN); +} pktle = pktl->head; if (pkt) @@ -873,6 +880,7 @@ int av_packet_list_get(AVPacketList *list, AVPacket *pkt, if (!pktle->next) pktl->tail = NULL; +ff_mutex_unlock(&pktl->mutex); av_freep(&pktle); @@ -891,14 +899,20 @@ int av_packet_list_peek(AVPacketList *list, AVPacket *pkt, AVPacket tmp = { 0 }; int ret; -if (!pktl->head) +ff_mutex_lock(&pktl->mutex); +if (!pktl->head) { +ff_mutex_unlock(&pktl->mutex); return AVERROR(EAGAIN); +} -if (!pkt) +if (!pkt) { + ff_mutex_unlock(&pktl->mutex); return 0; +} pktle = pktl->head; ret = av_packet_ref(&tmp, &pktle->pkt); +ff_mutex_unlock(&pktl->mutex); if (ret < 0) return ret; @@ -915,6 +929,7 @@ void av_packet_list_flush(AVPacketList *list) AVPacketList *pktl = list; #endif +ff_mutex_lock(&pktl->mutex); while (pktl->head) { PacketListEntry *pktle = pktl->head; pktl->head = pktle->next; @@ -923,16 +938,29 @@ void av_packet_list_flush(AVPacketList *list) } pktl->tail = NULL; +ff_mutex_unlock(&pktl->mutex); } void av_packet_list_free(AVPacketList **plist) { AVPacketList *list = *plist; +#if FF_API_PACKET_LIST +struct PacketList *pktl; +#else +AVPacketList *pktl; +#endif if (!list) return; +#if FF_API_PACKET_LIST +pktl = (struct PacketList *)list; +#else +pktl = list; +#endif + av_packet_list_flush(list); +ff_mutex_destroy(&pktl->mutex); av_freep(plist); } diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h index fd9637bc44..4cb3fb4bbd 100644 --- a/libavcodec/packet_internal.h +++ b/libavcodec/packet_internal.h @@ -21,6 +21,7 @@ #include +#include "libavutil/thread.h" #include "packet.h" typedef struct PacketListEntry { @@ -36,6 +37,7 @@ struct AVPacketList { #endif PacketListEntry *head; PacketListEntry *tail; +AVMutex mutex; }; #if LIBAVCODEC_VERSION_MAJOR < 59 -- 2.29.2 ___ 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] libavformat/mov.c: export vendor id as metadata
On Wed, Nov 18, 2020 at 10:56 AM Andreas Rheinhardt < andreas.rheinha...@gmail.com> wrote: > Thierry Foucu: > > --- > > libavformat/mov.c | 24 +-- > > ...hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 + > > .../fate/hapqa-extract-nosnappy-to-hapq-mov | 1 + > > tests/ref/fate/mov-zombie | 2 +- > > tests/ref/fate/rgb24-mkv | 4 ++-- > > 5 files changed, 27 insertions(+), 5 deletions(-) > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 2b90e31170..1f9163d658 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -2095,6 +2095,8 @@ static void mov_parse_stsd_video(MOVContext *c, > AVIOContext *pb, > > uint8_t codec_name[32] = { 0 }; > > int64_t stsd_start; > > unsigned int len; > > +int32_t id = 0; > > +char vendor_id[5]; > > > > /* The first 16 bytes of the video sample description are already > > * read in ff_mov_read_stsd_entries() */ > > @@ -2102,7 +2104,15 @@ static void mov_parse_stsd_video(MOVContext *c, > AVIOContext *pb, > > > > avio_rb16(pb); /* version */ > > avio_rb16(pb); /* revision level */ > > -avio_rb32(pb); /* vendor */ > > +id = avio_rb32(pb); /* vendor */ > > +if (id != 0) { > > +vendor_id[0] = (id >> 24) & 0xff; > > +vendor_id[1] = (id >> 16) & 0xff; > > +vendor_id[2] = (id >> 8) & 0xff; > > +vendor_id[3] = (id >> 0) & 0xff; > > +vendor_id[4] = 0; > > +av_dict_set(&st->metadata, "vendor_id", vendor_id, 0); > > +} > > avio_rb32(pb); /* temporal quality */ > > avio_rb32(pb); /* spatial quality */ > > > > @@ -2150,10 +2160,20 @@ static void mov_parse_stsd_audio(MOVContext *c, > AVIOContext *pb, > > { > > int bits_per_sample, flags; > > uint16_t version = avio_rb16(pb); > > +int32_t id = 0; > > +char vendor_id[5]; > > AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, > "compatible_brands", NULL, AV_DICT_MATCH_CASE); > > > > avio_rb16(pb); /* revision level */ > > -avio_rb32(pb); /* vendor */ > > +id = avio_rb32(pb); /* vendor */ > > +if (id != 0) { > > +vendor_id[0] = (id >> 24) & 0xff; > > +vendor_id[1] = (id >> 16) & 0xff; > > +vendor_id[2] = (id >> 8) & 0xff; > > +vendor_id[3] = (id >> 0) & 0xff; > > AV_WB32(). Alternatively, one could use av_fourcc2str() if you like its > handling of characters outside the [A-Za-z0-9._ -] set (but for this you > would need to read the number via avio_rl32()). > > Good to know about this API. Will send new patch > - Andreas > ___ > 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". -- Thierry Foucu ___ 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 00/18] AVPacketList public API
On 18/11/2020 16:52, James Almer wrote: > This is an attempt at introducing a public packet list API, after the > need for it outside of libavformat became evident. Can you mention what the intended use is outside of lavf, for those of us who may have missed the conversations around it? - Derek ___ 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] libavformat/mov.c: export vendor id as metadata
--- libavformat/mov.c | 8 ++-- tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 + tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov | 1 + tests/ref/fate/mov-zombie | 2 +- tests/ref/fate/rgb24-mkv | 4 ++-- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2b90e31170..1ba1a748e8 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2095,6 +2095,7 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, uint8_t codec_name[32] = { 0 }; int64_t stsd_start; unsigned int len; +uint32_t id = 0; /* The first 16 bytes of the video sample description are already * read in ff_mov_read_stsd_entries() */ @@ -2102,7 +2103,8 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, avio_rb16(pb); /* version */ avio_rb16(pb); /* revision level */ -avio_rb32(pb); /* vendor */ +id = avio_rl32(pb); /* vendor */ +av_dict_set(&st->metadata, "vendor_id", av_fourcc2str(id), 0); avio_rb32(pb); /* temporal quality */ avio_rb32(pb); /* spatial quality */ @@ -2150,10 +2152,12 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, { int bits_per_sample, flags; uint16_t version = avio_rb16(pb); +uint32_t id = 0; AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); avio_rb16(pb); /* revision level */ -avio_rb32(pb); /* vendor */ +id = avio_rl32(pb); /* vendor */ +av_dict_set(&st->metadata, "vendor_id", av_fourcc2str(id), 0); st->codecpar->channels = avio_rb16(pb); /* channel count */ st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* sample size */ diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov index 61af08aa23..04a965b12a 100644 --- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov +++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov @@ -69,5 +69,6 @@ DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:language=eng TAG:handler_name=Module de gestion video +TAG:vendor_id=FFMP TAG:encoder=HAPAlpha Only [/STREAM] diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov index 1fb31ec7f0..d9e5c94ffb 100644 --- a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov +++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov @@ -69,5 +69,6 @@ DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:language=eng TAG:handler_name=Module de gestion video +TAG:vendor_id=FFMP TAG:encoder=HAPQ [/STREAM] diff --git a/tests/ref/fate/mov-zombie b/tests/ref/fate/mov-zombie index 1a6625bc8f..c566b14d47 100644 --- a/tests/ref/fate/mov-zombie +++ b/tests/ref/fate/mov-zombie @@ -194,5 +194,5 @@ frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=188623|pkt_pts_time=2. packet|codec_type=video|stream_index=0|pts=197632|pts_time=2.195911|dts=191625|dts_time=2.129167|duration=3003|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=580|pos=101820|flags=__ frame|media_type=video|stream_index=0|key_frame=0|pkt_pts=191626|pkt_pts_time=2.129178|pkt_dts=N/A|pkt_dts_time=N/A|best_effort_timestamp=191626|best_effort_timestamp_time=2.129178|pkt_duration=3003|pkt_duration_time=0.033367|pkt_pos=99180|pkt_size=1666|width=160|height=240|pix_fmt=yuv420p|sample_aspect_ratio=2:1|pict_type=P|coded_picture_number=63|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=tv|color_space=smpte170m|color_primaries=smpte170m|color_transfer=bt709|chroma_location=topleftside_data|side_data_type=H.26[45] User Data Unregistered SEI message -stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_time_base=212521/12744000|codec_tag_string=avc1|codec_tag=0x31637661|width=160|height=240|coded_width=160|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=2:1|display_aspect_ratio=4:3|pix_fmt=yuv420p|level=12|color_range=tv|color_space=smpte170m|color_transfer=bt709|color_primaries=smpte170m|chroma_location=topleft|field_order=unknown|timecode=N/A|refs=2|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=3/1001|avg_frame_rate=6372000/212521|time_base=1/9|start_pts=0|start_time=0.00|duration_ts=2125200|duration=23.61|bit_rate=333874|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=708|nb_read_frames=65|nb_read_packets=66|disposition:default=1|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:rotate=0|tag:creation_time=2008-05-12T20:59:27.0
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: make sure mpegts_read_header always stops at the first pmt
On Sun, 15 Nov 2020, Ross Nicholson wrote: On Sat, 14 Nov 2020 at 23:40, Marton Balint wrote: mpegts_read_header stops parsing the file at the first PMT. However the check that ensured this was wrong because streams can also be added before the first PMT is received (e.g. EIT). So let's make sure we are in the header reading phase by checking if ts->pkt is unset instead of checking if the number of streams found so far is 0. Signed-off-by: Marton Balint --- libavformat/mpegts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 80d010db6c..a2003c6632 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2355,7 +2355,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len goto out; // stop parsing after pmt, we found header -if (!ts->stream->nb_streams) +if (!ts->pkt) ts->stop_parse = 2; set_pmt_found(ts, h->id); -- 2.26.2 ___ 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 for this. With this fix streams with embedded EIT data open in approx 1-1.5 seconds as opposed to 10-15 seconds without the fix. If possible also having this fix in the 4.3 branch as well as master would be great. Ok, will apply and backport. Regards, 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] http: support retry on connection error
On Tue, 17 Nov 2020, Eran Kornblau wrote: Hi, This patch adds 2 options to http: - reconnect_on_status - a list of http status codes that should be retried. the list can contain explicit status codes or the strings 4xx/5xx. - reconnect_on_err - reconnects on arbitrary errors during connect, e.g. ECONNRESET/ETIMEDOUT. The retry employs the same exponential backoff logic as the existing reconnect/reconnect_at_eof flags. Related tickets: https://trac.ffmpeg.org/ticket/6066 https://trac.ffmpeg.org/ticket/7768 From f412ca316f26f8c52d9763a33703ab06134feb37 Mon Sep 17 00:00:00 2001 From: erankor Date: Sun, 25 Oct 2020 15:25:13 +0200 Subject: [PATCH] http: support retry on connection error added 2 new options: - reconnect_on_status - a list of http status codes that should be retried. the list can contain explicit status codes / the strings 4xx/5xx. Maybe better name this option reconnect_on_http_error. Also this is a flags-like option, so use AV_OPT_TYPE_FLAGS with 4xx and 5xx as flags. - reconnect_on_err - reconnects on arbitrary errors during connect, e.g. ECONNRESET/ETIMEDOUT Maybe reconnect_on_network_error better reflects that this reconnects on underlying protocol (TCP/TLS) error. Anyhow, the new options should be added to docs/protocols.texi. the retry employs the same exponential backoff logic as the existing reconnect/reconnect_at_eof flags. related tickets: https://trac.ffmpeg.org/ticket/6066 https://trac.ffmpeg.org/ticket/7768 --- libavformat/http.c | 62 -- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 3d25d652d3..ea14ef0c47 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -119,8 +119,10 @@ typedef struct HTTPContext { char *method; int reconnect; int reconnect_at_eof; +int reconnect_on_err; int reconnect_streamed; int reconnect_delay_max; +char *reconnect_on_status; int listen; char *resource; int reply_code; @@ -164,6 +166,8 @@ static const AVOption options[] = { { "method", "Override the HTTP method or set the expected HTTP method from a client", OFFSET(method), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E }, { "reconnect", "auto reconnect after disconnect before EOF", OFFSET(reconnect), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D }, { "reconnect_at_eof", "auto reconnect at EOF", OFFSET(reconnect_at_eof), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D }, +{ "reconnect_on_err", "auto reconnect in case of tcp/tls error during connect", OFFSET(reconnect_on_err), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D }, +{ "reconnect_on_status", "list of http status codes to reconnect on. the list can include specific status codes / 4xx / 5xx", OFFSET(reconnect_on_status), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D }, AV_OPT_TYPE_FLAGS, as I explained above. { "reconnect_streamed", "auto reconnect streamed / non seekable streams", OFFSET(reconnect_streamed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D }, { "reconnect_delay_max", "max reconnect delay in seconds after which to give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000, D }, { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E }, @@ -258,21 +262,75 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) return location_changed; } +static int http_should_reconnect(HTTPContext *s, int err) +{ +const char *status_group; +char http_code[4]; + +switch (err) { +case AVERROR_HTTP_BAD_REQUEST: +case AVERROR_HTTP_UNAUTHORIZED: +case AVERROR_HTTP_FORBIDDEN: +case AVERROR_HTTP_NOT_FOUND: +case AVERROR_HTTP_OTHER_4XX: +status_group = "4xx"; +break; + +case AVERROR_HTTP_SERVER_ERROR: +status_group = "5xx"; +break; + +default: +return s->reconnect_on_err; +} + +if (!s->reconnect_on_status) { +return 0; +} + +if (av_match_list(status_group, s->reconnect_on_status, ',') > 0) { +return 1; +} + +snprintf(http_code, sizeof(http_code), "%d", s->http_code); + +return av_match_list(http_code, s->reconnect_on_status, ',') > 0; +} + /* return non zero if error */ static int http_open_cnx(URLContext *h, AVDictionary **options) { HTTPAuthType cur_auth_type, cur_proxy_auth_type; HTTPContext *s = h->priv_data; int location_changed, attempts = 0, redirects = 0; +int reconnect_delay = 0; +uint64_t off; + redo: av_dict_copy(options, s->chained_options, 0); cur_auth_type = s->auth_state.auth_type; cur_proxy_auth_type = s->auth_state.auth_type; +off = s->off; location_changed = http_open_cnx_internal(h, options); Are you sure you get AVERROR_HTTP_* here? Also if you follow the code there is special handling of 401/407, that should be done first befor
[FFmpeg-devel] [PATCH 2/3] avformat/cafdec: Check for EOF in index read loop
Fixes: OOM Fixes: 27398/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-541296033975500 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/cafdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index ec297dfa7d..1080f48891 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -202,6 +202,8 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size) st->duration = 0; for (i = 0; i < num_packets; i++) { +if (avio_feof(pb)) +return AVERROR_INVALIDDATA; av_add_index_entry(s->streams[0], pos, st->duration, 0, 0, AVINDEX_KEYFRAME); pos += caf->bytes_per_packet ? caf->bytes_per_packet : ff_mp4_read_descr_len(pb); st->duration += caf->frames_per_packet ? caf->frames_per_packet : ff_mp4_read_descr_len(pb); -- 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".
[FFmpeg-devel] [PATCH 3/3] avformat/swfdec: Allocate output buffer after reading input
Fixes: Timeout (>10sec -> 0.26sec) Fixes: 27419/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-5678307361947648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/swfdec.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index fa11c050cd..1463f0ad4d 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -368,14 +368,21 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize); zbuf = av_malloc(len); -buf = av_malloc(out_len); -if (!zbuf || !buf) { +if (!zbuf) { res = AVERROR(ENOMEM); goto bitmap_end; } len = avio_read(pb, zbuf, len); -if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) { +if (len < 0) +goto bitmap_end_skip; + +buf = av_malloc(out_len); +if (!buf) { +res = AVERROR(ENOMEM); +goto bitmap_end; +} +if ((res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) { av_log(s, AV_LOG_WARNING, "Failed to uncompress one bitmap\n"); goto bitmap_end_skip; } -- 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/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIG.
Hi, On Mon, Nov 16, 2020 at 2:36 PM Wonkap Jang wrote: > > In order to fine-control referencing schemes in VP9 encoding, there > is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit > provides a way to use the API through frame metadata. > --- > libavcodec/libvpxenc.c | 77 ++ The documentation could use an update too. Maybe some of the earlier per-frame metadata was missed. > 1 file changed, 77 insertions(+) > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index a7c76eb835..dbe399bf72 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -125,6 +125,11 @@ typedef struct VPxEncoderContext { > * encounter a frame with ROI side data. > */ > int roi_warned; > + > +#if (VPX_ENCODER_ABI_VERSION >= 12) && CONFIG_LIBVPX_VP9_ENCODER > +vpx_svc_ref_frame_config_t ref_frame_config; > +AVDictionary *vpx_ref_frame_config; > +#endif > } VPxContext; > > /** String mappings for enum vp8e_enc_control_id */ > @@ -152,6 +157,7 @@ static const char *const ctlidstr[] = { > [VP9E_SET_SVC_LAYER_ID]= "VP9E_SET_SVC_LAYER_ID", > #if VPX_ENCODER_ABI_VERSION >= 12 This check isn't sufficient since the vpx_svc_ref_frame_config_t struct was changed a few times after this point. > [VP9E_SET_SVC_PARAMETERS] = "VP9E_SET_SVC_PARAMETERS", > +[VP9E_SET_SVC_REF_FRAME_CONFIG]= "VP9E_SET_SVC_REF_FRAME_CONFIG", > #endif > [VP9E_SET_SVC] = "VP9E_SET_SVC", > #if VPX_ENCODER_ABI_VERSION >= 11 > @@ -394,6 +400,18 @@ static void vp8_ts_parse_int_array(int *dest, char > *value, size_t value_len, int > } > } > > +static void vp8_ts_parse_int64_array(int64_t *dest, char *value, size_t > value_len, int max_entries) > +{ > +int dest_idx = 0; > +char *saveptr = NULL; > +char *token = av_strtok(value, ",", &saveptr); > + > +while (token && dest_idx < max_entries) { > +dest[dest_idx++] = strtoul(token, NULL, 10); int64 seems like it was overkill in the api, but you probably want strtoull here. ___ 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 1/3] avformat/cafdec: clip sample rate
Fixes: 1.21126e+111 is outside the range of representable values of type 'int' Fixes: 27398/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5412960339755008 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/cafdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 3bf1fa64bc..ec297dfa7d 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -70,7 +70,7 @@ static int read_desc_chunk(AVFormatContext *s) /* parse format description */ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; -st->codecpar->sample_rate = av_int2double(avio_rb64(pb)); +st->codecpar->sample_rate = av_clipd(av_int2double(avio_rb64(pb)), 0, INT_MAX); st->codecpar->codec_tag = avio_rl32(pb); flags = avio_rb32(pb); caf->bytes_per_packet = avio_rb32(pb); -- 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 10/18] lavf: move AVStream.*index_entries* to AVStreamInternal
On Mon, Nov 16, 2020 at 09:46:01PM -0300, James Almer wrote: > On 11/16/2020 12:25 PM, Hendrik Leppkes wrote: > > On Mon, Nov 16, 2020 at 4:20 PM James Almer wrote: > > > > > > On 11/16/2020 3:01 AM, Anton Khirnov wrote: > > > > Quoting Xiang, Haihao (2020-11-16 06:16:55) > > > > > > > > > > This change breaks the compiling of gst-libav ( > > > > > https://gitlab.freedesktop.org/gstreamer/gst-libav), I filed > > > > > https://trac.ffmpeg.org/ticket/8988 to track this regression. > > > > > > > > This is not a regression, it's a bug in gst-libav. These fields are > > > > private and have always been private, applications accessing them are > > > > broken. > > > > > > Looking at that ticket, it seems gst-libav wants the timestamp for a > > > given index entry. Unless this can already be achieved in some other > > > way, it could maybe be implemented cleanly with a new public function > > > (We have av_index_search_timestamp() to fetch an index from a timestamp > > > after all). > > > > I also like being able to access the index, it can be used by players > > to efficiently offer seeking straight to keyframes (eg. index > > entries), which basically requires iterating over the full index and > > getting the full information (timestamp, flags at least) > > > > - Hendrik > > What do you suggest, implement something like what you added to you > LAVFilters fork? I don't know if returning a pointer to a given AVIndexEntry > is ideal. If that were the case, then it wouldn't be an internal field. > > Perhaps something like > > int av_index_get_entries_count(AVStream *st); > int av_index_get_timestamp(AVStream *st, int64_t *timestamp, int *flags, int > idx); If the (only) goal is to export the whole list then a better option might be to use an opaque state and some sort of iterator. Because the suggestion requires N index based lookups and this is only fast with some conceivable implementations. for example consider an index stored in some sort of tree structure a index based lookup might be O(log n) while one step iterating over all elements could be O(1) AVIndexEntry *av_index_iterate(AVStream *st, AVIndexIterator **i); and AVIndexIterator *i = NULL; AVIndexEntry *entry; for (entry = av_index_iterate(st, &i); i; entry = av_index_iterate(st, &i)) ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu signature.asc Description: PGP 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".
Re: [FFmpeg-devel] [PATCH 10/18] lavf: move AVStream.*index_entries* to AVStreamInternal
On 11/18/2020 6:41 PM, Michael Niedermayer wrote: On Mon, Nov 16, 2020 at 09:46:01PM -0300, James Almer wrote: On 11/16/2020 12:25 PM, Hendrik Leppkes wrote: On Mon, Nov 16, 2020 at 4:20 PM James Almer wrote: On 11/16/2020 3:01 AM, Anton Khirnov wrote: Quoting Xiang, Haihao (2020-11-16 06:16:55) This change breaks the compiling of gst-libav ( https://gitlab.freedesktop.org/gstreamer/gst-libav), I filed https://trac.ffmpeg.org/ticket/8988 to track this regression. This is not a regression, it's a bug in gst-libav. These fields are private and have always been private, applications accessing them are broken. Looking at that ticket, it seems gst-libav wants the timestamp for a given index entry. Unless this can already be achieved in some other way, it could maybe be implemented cleanly with a new public function (We have av_index_search_timestamp() to fetch an index from a timestamp after all). I also like being able to access the index, it can be used by players to efficiently offer seeking straight to keyframes (eg. index entries), which basically requires iterating over the full index and getting the full information (timestamp, flags at least) - Hendrik What do you suggest, implement something like what you added to you LAVFilters fork? I don't know if returning a pointer to a given AVIndexEntry is ideal. If that were the case, then it wouldn't be an internal field. Perhaps something like int av_index_get_entries_count(AVStream *st); int av_index_get_timestamp(AVStream *st, int64_t *timestamp, int *flags, int idx); If the (only) goal is to export the whole list then a better option might be to use an opaque state and some sort of iterator. The index entries are in a flat array. A function like what i suggested above would simply do st->internal->index_entries[idx]. Because the suggestion requires N index based lookups and this is only fast with some conceivable implementations. for example consider an index stored in some sort of tree structure a index based lookup might be O(log n) while one step iterating over all elements could be O(1) AVIndexEntry *av_index_iterate(AVStream *st, AVIndexIterator **i); and AVIndexIterator *i = NULL; AVIndexEntry *entry; for (entry = av_index_iterate(st, &i); i; entry = av_index_iterate(st, &i)) ... But do we want to return a pointer to an entry in the index array, or just some of the fields for a given entry? As i said above, if the former was intended, then it wouldn't have been an internal field all this time to being with. [...] ___ 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 v2 0/7] HEVC native support for Screen content coding
On Thu, Oct 29, 2020 at 02:57:13PM +0100, Christophe Gisquet wrote: > Hi, > > Le mar. 29 sept. 2020 à 17:55, Linjie Fu a écrit > : > > I didn’t see such plans for now, hence adding sufficient error message > > seems to be a proper way. > > Hi, as you are the only one active on this decoder, this shouldn't matter, > but: > down the line, the ffmpeg project has no way of testing if someone > breaks even the basic parsing of these extensions in the future. > To test, the hardware you mention is needed, as well as maybe specific tests. > > At some point, fate lacks some support for verifying h/w decoding. It > would be really nice if some of these companies with all this new > awesome hardware would consider this, and for instance contribute fate > instances to perform such test for the ffmpeg project. I agree! thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Nations do behave wisely once they have exhausted all other alternatives. -- Abba Eban signature.asc Description: PGP 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".
Re: [FFmpeg-devel] [PATCH 00/18] AVPacketList public API
On 11/18/2020 5:03 PM, Derek Buitenhuis wrote: On 18/11/2020 16:52, James Almer wrote: This is an attempt at introducing a public packet list API, after the need for it outside of libavformat became evident. Can you mention what the intended use is outside of lavf, for those of us who may have missed the conversations around it? It's currently used in decode.c in libavcodec, and on three devices in libavdevice, hence the avpriv_ implementation. It's also reimplemented in ffplay, which could be ported to this API if we add some sort of opaque user field to be attached to each packet in the list. ffplay is a library user, so there's clearly interest for a packet queue outside of libav*. - Derek ___ 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] [RFC][PATCH 18/18] avcodec/avpacket: make the AVPacketList API thread safe
On 11/18/2020 5:08 PM, Marton Balint wrote: On Wed, 18 Nov 2020, James Almer wrote: Signed-off-by: James Almer --- I don't know if this is necessary, so i'm sending it as an RFC. I don't think this API should provide locking by default, maybe as an option. But considering that it was not often needed so far, and the API can be wrapped into locked versions (like decklink does) relatively easily, I think it is fine as is. My worry was adding a linked list public API that's not thread safe. The other example we have is AVBufferPool, which does locking unconditionally by itself before adding or removing elements from the list, so it's valid to assume this one should maybe do the same. ___ 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] Next developer meeting
> 2020年11月18日 下午8:59,Thilo Borgmann 写道: > > Hi, > >> we haven't had a meeting for quite some time and are beyond schedule anyway. >> So I'd propose having another developer meeting before end of year. >> >> Please give your preferences for a date here: >> https://framadate.org/g1FPmOpfEz9mSLg9 > > one week later, we have settled for having the FFDev meeting on > > Saturday, Dec 5th. > > Based on last time, I told we aim for 17 UTC for the vote. Steven made some > comments I don't fully understand... > > If someone want to shift it, please propose a better time. An overview might > be: > https://www.timeanddate.de/zeitzonen/konferenz?iso=20201205&p1=224&p2=37&p3=33 What about shift to 16 UTC? Because it’s 01:00:00 AM in Peking if aim 17 UTC. :D > > >> Current agenda proposals, feel free to add to it: >> >> - Tech / Comm committees how-to in practice >> - GSoC adaptations for upcoming years >> - splitting libraries (lavf->lavio) >> - writing down development rules >> - switching to a merge request-like system >> - ... > > > -Thilo > ___ > 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".
Re: [FFmpeg-devel] Next developer meeting
On 19/11/20 1:46 pm, Steven Liu wrote: 2020年11月18日 下午8:59,Thilo Borgmann 写道: Hi, we haven't had a meeting for quite some time and are beyond schedule anyway. So I'd propose having another developer meeting before end of year. Please give your preferences for a date here: https://framadate.org/g1FPmOpfEz9mSLg9 one week later, we have settled for having the FFDev meeting on Saturday, Dec 5th. Based on last time, I told we aim for 17 UTC for the vote. Steven made some comments I don't fully understand... If someone want to shift it, please propose a better time. An overview might be: https://www.timeanddate.de/zeitzonen/konferenz?iso=20201205&p1=224&p2=37&p3=33 What about shift to 16 UTC? Because it’s 01:00:00 AM in Peking if aim 17 UTC. :D I've got it even worse, 1700 UTC is 3AM for me (Australia, UTC+10). Shifting back even further to 1300/1400 UTC (11pm/12am) would be greatly appreciated (if even possible). Zane ___ 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 v2] avdevice/decklink_dec: map the raw_format instead of hardcode
On Wed, Nov 18, 2020 at 07:37:40PM +0100, Marton Balint wrote: > > > On Sat, 14 Nov 2020, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > Well, this patch changes the numerical values for the string constants. We > sometimes do that, and probably it is cleaner if we do mapping the same way > we do with other options, but a libavdevice micro bump is definitely needed > for the change. will bump the micro version > > > > > Signed-off-by: Limin Wang > > --- > > libavdevice/decklink_common.h | 9 + > > libavdevice/decklink_dec.cpp | 3 ++- > > libavdevice/decklink_dec_c.c | 12 ++-- > > 3 files changed, 17 insertions(+), 7 deletions(-) > > > > diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h > > index f35bd9a..ac15488 100644 > > --- a/libavdevice/decklink_common.h > > +++ b/libavdevice/decklink_common.h > > @@ -162,6 +162,15 @@ IDeckLinkIterator > > *CreateDeckLinkIteratorInstance(void); > > typedef uint32_t buffercount_type; > > #endif > > > > +static const BMDPixelFormat decklink_raw_format_map[] = { > > +BMDPixelFormat(0), > > Please follow the C syntax: (BMDPixelFormat)0 OK, will change it > > > +bmdFormat8BitYUV, > > +bmdFormat10BitYUV, > > +bmdFormat8BitARGB, > > +bmdFormat8BitBGRA, > > +bmdFormat10BitRGB, > > +}; > > + > > static const BMDAudioConnection decklink_audio_connection_map[] = { > > (BMDAudioConnection)0, > > bmdAudioConnectionEmbedded, > > diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp > > index 6517b9d..049e133 100644 > > --- a/libavdevice/decklink_dec.cpp > > +++ b/libavdevice/decklink_dec.cpp > > @@ -1152,7 +1152,8 @@ av_cold int ff_decklink_read_header(AVFormatContext > > *avctx) > > ctx->video_pts_source = cctx->video_pts_source; > > ctx->draw_bars = cctx->draw_bars; > > ctx->audio_depth = cctx->audio_depth; > > -ctx->raw_format = (BMDPixelFormat)cctx->raw_format; > > +if (cctx->raw_format > 0 && (unsigned int)cctx->raw_format < > > FF_ARRAY_ELEMS(decklink_raw_format_map)) > > +ctx->raw_format = decklink_raw_format_map[cctx->raw_format]; > > cctx->ctx = ctx; > > > > /* Check audio channel option for valid values: 2, 8 or 16 */ > > diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c > > index f3fdcd3..66786db 100644 > > --- a/libavdevice/decklink_dec_c.c > > +++ b/libavdevice/decklink_dec_c.c > > @@ -34,12 +34,12 @@ static const AVOption options[] = { > > { "list_formats", "list supported formats" , OFFSET(list_formats), > > AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, > > { "format_code", "set format by fourcc", OFFSET(format_code), > > AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC }, > > { "raw_format", "pixel format to be returned by the card when > > capturing" , OFFSET(raw_format), AV_OPT_TYPE_INT, { .i64 = 0}, 0, > > UINT_MAX, DEC, "raw_format" }, > > The maximum should also be updated. will update the maximum range > > > -{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 > > }, 0, 0, DEC, "raw_format"}, > > -{ "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > > MKBETAG('2','v','u','y') }, 0, 0, DEC, "raw_format"}, > > -{ "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > > MKBETAG('v','2','1','0') }, 0, 0, DEC, "raw_format"}, > > -{ "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 32 > > }, 0, 0, DEC, "raw_format"}, > > -{ "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > > MKBETAG('B','G','R','A') }, 0, 0, DEC, "raw_format"}, > > -{ "rgb10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > > MKBETAG('r','2','1','0') }, 0, 0, DEC, "raw_format"}, > > +{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, > > DEC, "raw_format"}, > > +{ "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, > > DEC, "raw_format"}, > > +{ "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, > > DEC, "raw_format"}, > > +{ "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, 0, 0, > > DEC, "raw_format"}, > > +{ "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, 0, 0, > > DEC, "raw_format"}, > > +{ "rgb10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 5 }, 0, 0, > > DEC, "raw_format"}, > > { "enable_klv","output klv if present in vanc", OFFSET(enable_klv), > > AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC }, > > { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), > > AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7LL, DEC, "teletext_lines"}, > > { "standard", NULL, 0, > > AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0,DEC, "teletext_lines"}, > > Regards, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.or
Re: [FFmpeg-devel] Next developer meeting
> 2020年11月19日 下午12:05,Zane van Iperen 写道: > > > > On 19/11/20 1:46 pm, Steven Liu wrote: >>> 2020年11月18日 下午8:59,Thilo Borgmann 写道: >>> >>> Hi, >>> we haven't had a meeting for quite some time and are beyond schedule anyway. So I'd propose having another developer meeting before end of year. Please give your preferences for a date here: https://framadate.org/g1FPmOpfEz9mSLg9 >>> >>> one week later, we have settled for having the FFDev meeting on >>> >>> Saturday, Dec 5th. >>> >>> Based on last time, I told we aim for 17 UTC for the vote. Steven made some >>> comments I don't fully understand... >>> >>> If someone want to shift it, please propose a better time. An overview >>> might be: >>> https://www.timeanddate.de/zeitzonen/konferenz?iso=20201205&p1=224&p2=37&p3=33 >> What about shift to 16 UTC? >> Because it’s 01:00:00 AM in Peking if aim 17 UTC. :D >>> > > I've got it even worse, 1700 UTC is 3AM for me (Australia, UTC+10). Shifting > back even further > to 1300/1400 UTC (11pm/12am) would be greatly appreciated (if even possible). Not only no problem but also feel happy in Peking. Haha :D > > Zane > ___ > 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".
Re: [FFmpeg-devel] [PATCH 6/6] avutil/frame: use av_buffer_replace() to simplify code
Quoting Gil Pedersen (2020-11-18 14:05:17) > Also fixes potential leaks in failing av_frame_ref(). > > Signed-off-by: Gil Pedersen > --- Looks ok -- Anton Khirnov ___ 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 5/6] avcodec/wavpack: use av_buffer_replace() to simplify code
Quoting Gil Pedersen (2020-11-18 14:05:16) > Signed-off-by: Gil Pedersen > --- > libavcodec/wavpack.c | 7 +++ > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c > index f77548e5a5..58122c948c 100644 > --- a/libavcodec/wavpack.c > +++ b/libavcodec/wavpack.c > @@ -1024,13 +1024,12 @@ static int update_thread_context(AVCodecContext *dst, > const AVCodecContext *src) > return ret; > } > > -av_buffer_unref(&fdst->dsd_ref); > fdst->dsdctx = NULL; > fdst->dsd_channels = 0; > +ret = av_buffer_replace(&fdst->dsd_ref, fsrc->dsd_ref); > +if (ret < 0) > +return ret; > if (fsrc->dsd_ref) { > -fdst->dsd_ref = av_buffer_ref(fsrc->dsd_ref); > -if (!fdst->dsd_ref) > -return AVERROR(ENOMEM); > fdst->dsdctx = (DSDContext*)fdst->dsd_ref->data; > fdst->dsd_channels = fsrc->dsd_channels; > } > -- > 2.17.1 Ok. -- Anton Khirnov ___ 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 4/6] avcodec/h264_slice: use av_buffer_replace() to simplify code
Quoting Gil Pedersen (2020-11-18 14:05:15) > Signed-off-by: Gil Pedersen > --- > libavcodec/h264_slice.c | 10 +- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c > index fa7a639053..b937ebebcf 100644 > --- a/libavcodec/h264_slice.c > +++ b/libavcodec/h264_slice.c > @@ -1018,11 +1018,11 @@ static int h264_init_ps(H264Context *h, const > H264SliceContext *sl, int first_sl > int needs_reinit = 0, must_reinit, ret; > > if (first_slice) { > -av_buffer_unref(&h->ps.pps_ref); > -h->ps.pps = NULL; > -h->ps.pps_ref = av_buffer_ref(h->ps.pps_list[sl->pps_id]); > -if (!h->ps.pps_ref) > -return AVERROR(ENOMEM); > +ret = av_buffer_replace(&h->ps.pps_ref, h->ps.pps_list[sl->pps_id]); > +if (ret < 0) { > +h->ps.pps = NULL; You should probably unref pps_ref on failure too, av_buffer_replace() leaves the original on failure. -- Anton Khirnov ___ 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".