Re: [FFmpeg-devel] [PATCH] avutil/buffer: free all pooled buffers immediately after uninitializing the pool

2021-02-24 Thread Anton Khirnov
Quoting James Almer (2021-02-20 14:21:47)
> No buffer will be fetched from the pool after it's uninitialized, so there's
> no benefit from waiting until every single buffer has been returned to it
> before freeing them all.
> This should free some memory in certain scenarios, which can be beneficial in
> low memory systems.
> 
> Based on a patch by Jonas Karlman.
> 
> Signed-off-by: James Almer 
> ---
>  libavutil/buffer.c | 19 ++-
>  1 file changed, 14 insertions(+), 5 deletions(-)

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".

[FFmpeg-devel] Re: [PATCH 2/6] lavc: split LSCR decoder out of PNG decoder

2021-02-24 Thread Anton Khirnov
Quoting James Almer (2021-02-20 15:38:42)
> > +
> > +static void handle_row(LSCRContext *s, AVFrame *frame)
> 
> Unused frame argument.

Right, dropped locally.

> > +static int decode_frame_lscr(AVCodecContext *avctx,
> > + void *data, int *got_frame,
> > + AVPacket *avpkt)
> > +{
> > +LSCRContext *const s = avctx->priv_data;
> > +GetByteContext *gb = &s->gb;
> > +AVFrame *frame = data;
> > +int ret, nb_blocks, offset = 0;
> > +
> > +if (avpkt->size < 2)
> > +return AVERROR_INVALIDDATA;
> > +if (avpkt->size == 2)
> > +return 0;
> > +
> > +bytestream2_init(gb, avpkt->data, avpkt->size);
> > +
> > +if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
> > +return ret;
> > +
> > +nb_blocks = bytestream2_get_le16(gb);
> > +if (bytestream2_get_bytes_left(gb) < 2 + nb_blocks * (12 + 8))
> > +return AVERROR_INVALIDDATA;
> > +
> > +if (s->last_picture->data[0]) {
> > +ret = av_frame_copy(frame, s->last_picture);
> 
> You could use ff_reget_buf() instead. And if nb_blocks can be 0 (meaning 
> no changes since the previous frame), you could even use the 
> FF_REGET_BUFFER_FLAG_READONLY flag and completely avoid any memcpy.

Good idea, but I'd do it in a separate patch, so that the split is
closer to just a move.

-- 
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".

[FFmpeg-devel] [PATCH] lavc/lscrdec: use ff_reget_buffer()

2021-02-24 Thread Anton Khirnov
It is simpler and more efficient.

Suggested-by: James Almer 
---
 libavcodec/lscrdec.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/libavcodec/lscrdec.c b/libavcodec/lscrdec.c
index d5388c22ac..e706dda9da 100644
--- a/libavcodec/lscrdec.c
+++ b/libavcodec/lscrdec.c
@@ -105,7 +105,7 @@ static int decode_frame_lscr(AVCodecContext *avctx,
 {
 LSCRContext *const s = avctx->priv_data;
 GetByteContext *gb = &s->gb;
-AVFrame *frame = data;
+AVFrame *frame = s->last_picture;
 int ret, nb_blocks, offset = 0;
 
 if (avpkt->size < 2)
@@ -115,18 +115,14 @@ static int decode_frame_lscr(AVCodecContext *avctx,
 
 bytestream2_init(gb, avpkt->data, avpkt->size);
 
-if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
-return ret;
-
 nb_blocks = bytestream2_get_le16(gb);
 if (bytestream2_get_bytes_left(gb) < 2 + nb_blocks * (12 + 8))
 return AVERROR_INVALIDDATA;
 
-if (s->last_picture->data[0]) {
-ret = av_frame_copy(frame, s->last_picture);
-if (ret < 0)
-return ret;
-}
+ret = ff_reget_buffer(avctx, frame,
+  nb_blocks ? 0 : FF_REGET_BUFFER_FLAG_READONLY);
+if (ret < 0)
+return ret;
 
 for (int b = 0; b < nb_blocks; b++) {
 int x, y, x2, y2, w, h, left;
@@ -216,8 +212,7 @@ static int decode_frame_lscr(AVCodecContext *avctx,
 
 frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : 
AV_PICTURE_TYPE_P;
 
-av_frame_unref(s->last_picture);
-if ((ret = av_frame_ref(s->last_picture, frame)) < 0)
+if ((ret = av_frame_ref(data, frame)) < 0)
 return ret;
 
 *got_frame = 1;
-- 
2.28.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] Re: [PATCH 4/4] fftools/ffmpeg: drop an FF_API-guarded block

2021-02-24 Thread Anton Khirnov
Quoting James Almer (2021-01-26 18:19:46)
> On 1/26/2021 2:01 PM, Anton Khirnov wrote:
> > These macros are private and should not be used by external callers.
> > ---
> >   fftools/ffmpeg_opt.c | 13 -
> >   1 file changed, 13 deletions(-)
> > 
> > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> > index bf2eb26246..472016b93c 100644
> > --- a/fftools/ffmpeg_opt.c
> > +++ b/fftools/ffmpeg_opt.c
> > @@ -2423,19 +2423,6 @@ loop_end:
> >   avio_closep(&pb);
> >   }
> >   
> > -#if FF_API_LAVF_AVCTX
> > -for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; 
> > i++) { //for all streams of this output file
> > -AVDictionaryEntry *e;
> > -ost = output_streams[i];
> > -
> > -if ((ost->stream_copy || ost->attachment_filename)
> > -&& (e = av_dict_get(o->g->codec_opts, "flags", NULL, 
> > AV_DICT_IGNORE_SUFFIX))
> > -&& (!e->key[5] || check_stream_specifier(oc, ost->st, 
> > e->key+6)))
> > -if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
> > -exit_program(1);
> > -}
> > -#endif
> 
> I think this is here for the sake of a warning in libavformat/mux.c, 
> where if you use -flags +bitexact but not -fflags +bitexact it would 
> tell you to check that's what you intended to do.
> 
> If you remove this chunk, then might as well remove the warning in mux.c
> It's also guarded by a FF_API_LAVF_AVCTX check for obvious reasons.

Meh. Guess I'll postpone both until the actual bump then.

-- 
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] vp9dec: support exporting QP tables through the AVVideoEncParams API

2021-02-24 Thread Anton Khirnov
Quoting James Almer (2021-02-19 17:28:57)
> On 5/11/2020 6:32 AM, Anton Khirnov wrote:
> > ---
> > Now the nb_block_structure reset is moved to decode_frame_header(),
> > which fixes block-structure export with frame threading. No idea how I
> > didn't notice this before
> 
> Thread sanitizer complains about a race with this change.
> 
> http://fate.ffmpeg.org/report.cgi?time=20210218211624&slot=x86_64-archlinux-gcc-tsan
> 
> Look for vp9-encparams.
> 
> For that matter, tsan fate results are a mess. Lots of noise that makes 
> noticing new regressions hard.

Thanks, sending a fix.

-- 
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".

[FFmpeg-devel] [PATCH] vp9: fix a race in exporting encoding parameters

2021-02-24 Thread Anton Khirnov
Modifying shared state after ff_thread_finish_setup() is not allowed, so
set the encoding parameters directly on the output frame.

Found-by: James Almer 
---
 libavcodec/vp9.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 4659f94ee8..46062f8a8f 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -1499,7 +1499,8 @@ int loopfilter_proc(AVCodecContext *avctx)
 }
 #endif
 
-static int vp9_export_enc_params(VP9Context *s, VP9Frame *frame)
+static int vp9_export_enc_params(VP9Context *s, AVFrame *frame_dst,
+ const VP9Frame *frame)
 {
 AVVideoEncParams *par;
 unsigned int tile, nb_blocks = 0;
@@ -1509,7 +1510,7 @@ static int vp9_export_enc_params(VP9Context *s, VP9Frame 
*frame)
 nb_blocks += s->td[tile].nb_block_structure;
 }
 
-par = av_video_enc_params_create_side_data(frame->tf.f,
+par = av_video_enc_params_create_side_data(frame_dst,
 AV_VIDEO_ENC_PARAMS_VP9, nb_blocks);
 if (!par)
 return AVERROR(ENOMEM);
@@ -1759,12 +1760,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->td->error_info = 0;
 return AVERROR_INVALIDDATA;
 }
-if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
-ret = vp9_export_enc_params(s, &s->s.frames[CUR_FRAME]);
-if (ret < 0)
-return ret;
-}
-
 finish:
 // ref frame setup
 for (i = 0; i < 8; i++) {
@@ -1778,6 +1773,13 @@ finish:
 if (!s->s.h.invisible) {
 if ((ret = av_frame_ref(frame, s->s.frames[CUR_FRAME].tf.f)) < 0)
 return ret;
+
+if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+ret = vp9_export_enc_params(s, frame, &s->s.frames[CUR_FRAME]);
+if (ret < 0)
+return ret;
+}
+
 *got_frame = 1;
 }
 
-- 
2.28.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Handle AVID MJPEG streams directly in the MJPEG decoder.

2021-02-24 Thread Anton Khirnov
AVID streams - currently handled by the AVRN decoder - can be (depending
on extradata contents) either MJPEG or raw video. To decode the MJPEG
variant, the AVRN decoder currently instantiates a MJPEG decoder
internally and forwards decoded frames to the caller (possibly after
cropping them).

This is suboptimal, because the AVRN decoder does not forward all the
features of the internal MJPEG decoder, such as direct rendering.
Handling such forwarding in a full and generic manner would be quite
hard, so it is simpler to just handle those streams in the MJPEG decoder
directly.

The AVRN decoder, which now handles only the raw streams, can now be
marked as supporting direct rendering.

This also removes the last remaining internal use of the obsolete
decoding API.
---
 configure |  1 -
 libavcodec/Makefile   |  2 +-
 libavcodec/avrndec.c  | 74 ++-
 libavcodec/mjpegdec.c | 11 +++
 libavcodec/version.h  |  2 +-
 libavformat/avidec.c  |  6 
 libavformat/isom.c|  4 +--
 tests/fate/video.mak  |  2 +-
 8 files changed, 24 insertions(+), 78 deletions(-)

diff --git a/configure b/configure
index 336301cb40..0b97f81f8c 100755
--- a/configure
+++ b/configure
@@ -2688,7 +2688,6 @@ atrac3p_decoder_select="mdct sinewin"
 atrac3pal_decoder_select="mdct sinewin"
 atrac9_decoder_select="mdct"
 av1_decoder_select="cbs_av1"
-avrn_decoder_select="exif jpegtables"
 bink_decoder_select="blockdsp hpeldsp"
 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6ec1d360ac..b46c1688cc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -231,7 +231,7 @@ OBJS-$(CONFIG_AURA_DECODER)+= cyuv.o
 OBJS-$(CONFIG_AURA2_DECODER)   += aura.o
 OBJS-$(CONFIG_AV1_DECODER) += av1dec.o
 OBJS-$(CONFIG_AV1_CUVID_DECODER)   += cuviddec.o
-OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o mjpegdec.o
+OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o
 OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o
 OBJS-$(CONFIG_AVRP_ENCODER)+= r210enc.o
 OBJS-$(CONFIG_AVS_DECODER) += avs.o
diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index d85e3c2000..a80851cefa 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -21,13 +21,10 @@
 
 #include "avcodec.h"
 #include "internal.h"
-#include "mjpeg.h"
-#include "mjpegdec.h"
+
 #include "libavutil/imgutils.h"
 
 typedef struct {
-AVCodecContext *mjpeg_avctx;
-int is_mjpeg;
 int interlace;
 int tff;
 } AVRnContext;
@@ -37,42 +34,6 @@ static av_cold int init(AVCodecContext *avctx)
 AVRnContext *a = avctx->priv_data;
 int ret;
 
-// Support "Resolution 1:1" for Avid AVI Codec
-a->is_mjpeg = avctx->extradata_size < 31 || memcmp(&avctx->extradata[28], 
"1:1", 3);
-
-if(!a->is_mjpeg && avctx->lowres) {
-av_log(avctx, AV_LOG_ERROR, "lowres is not possible with rawvideo\n");
-return AVERROR(EINVAL);
-}
-
-if(a->is_mjpeg) {
-const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
-AVDictionary *thread_opt = NULL;
-if (!codec) {
-av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
-return AVERROR_DECODER_NOT_FOUND;
-}
-
-a->mjpeg_avctx = avcodec_alloc_context3(codec);
-if (!a->mjpeg_avctx)
-return AVERROR(ENOMEM);
-
-av_dict_set(&thread_opt, "threads", "1", 0); // Is this needed ?
-a->mjpeg_avctx->refcounted_frames = 1;
-a->mjpeg_avctx->flags = avctx->flags;
-a->mjpeg_avctx->idct_algo = avctx->idct_algo;
-a->mjpeg_avctx->lowres = avctx->lowres;
-a->mjpeg_avctx->width = avctx->width;
-a->mjpeg_avctx->height = avctx->height;
-
-if ((ret = avcodec_open2(a->mjpeg_avctx, codec, &thread_opt)) < 0) {
-av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
-}
-av_dict_free(&thread_opt);
-
-return ret;
-}
-
 if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
 return ret;
 
@@ -89,15 +50,6 @@ static av_cold int init(AVCodecContext *avctx)
 return 0;
 }
 
-static av_cold int end(AVCodecContext *avctx)
-{
-AVRnContext *a = avctx->priv_data;
-
-avcodec_free_context(&a->mjpeg_avctx);
-
-return 0;
-}
-
 static int decode_frame(AVCodecContext *avctx, void *data,
 int *got_frame, AVPacket *avpkt)
 {
@@ -107,28 +59,6 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 int buf_size   = avpkt->size;
 int y, ret, true_height;
 
-if(a->is_mjpeg) {
-ret = avcodec_decode_video2(a->mjpeg_avctx, data, got_frame, avpkt);
-
-if (ret >= 0 && *got_frame && avctx->width <= p->width && 
avctx->height <= p->height) {
-int shift = p->height - avctx->height;
-int subsample_h, s

[FFmpeg-devel] [PATCH 1/5] tests/api-band-test: simplify code

2021-02-24 Thread Anton Khirnov
---
 tests/api/api-band-test.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
index 34bed1d6be..717c9441a4 100644
--- a/tests/api/api-band-test.c
+++ b/tests/api/api-band-test.c
@@ -167,10 +167,8 @@ static int video_decode(const char *input_filename)
 continue;
 }
 
-if (result < 0)
-result = avcodec_send_packet(ctx, NULL);
-else
-result = avcodec_send_packet(ctx, pkt);
+// pkt will be empty on read error/EOF
+result = avcodec_send_packet(ctx, pkt);
 
 av_packet_unref(pkt);
 
-- 
2.28.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 5/5] lavc: remove tests/options

2021-02-24 Thread Anton Khirnov
It tests deprecated avcodec_copy_context().
---
 libavcodec/Makefile|   1 -
 libavcodec/tests/options.c | 194 -
 tests/fate/libavcodec.mak  |   4 -
 3 files changed, 199 deletions(-)
 delete mode 100644 libavcodec/tests/options.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b46c1688cc..097e7ecd5a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1220,7 +1220,6 @@ TESTPROGS = avpacket  
  \
 imgconvert  \
 jpeg2000dwt \
 mathops\
-options \
 mjpegenc_huffman\
 utils   \
 
diff --git a/libavcodec/tests/options.c b/libavcodec/tests/options.c
deleted file mode 100644
index 010e3c0145..00
--- a/libavcodec/tests/options.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer 
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavcodec/options.c"
-
-static int dummy_init(AVCodecContext *ctx)
-{
-//TODO: this code should set every possible pointer that could be set by 
codec and is not an option;
-ctx->extradata_size = 8;
-ctx->extradata = av_malloc(ctx->extradata_size);
-return 0;
-}
-
-static int dummy_close(AVCodecContext *ctx)
-{
-av_freep(&ctx->extradata);
-ctx->extradata_size = 0;
-return 0;
-}
-
-static int dummy_encode(AVCodecContext *ctx, AVPacket *pkt, const AVFrame 
*frame, int *got_packet)
-{
-return AVERROR(ENOSYS);
-}
-
-typedef struct Dummy12Context {
-AVClass  *av_class;
-int  num;
-char*str;
-} Dummy12Context;
-
-typedef struct Dummy3Context {
-void *fake_av_class;
-int  num;
-char*str;
-} Dummy3Context;
-
-#define OFFSET(x) offsetof(Dummy12Context, x)
-#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
-static const AVOption dummy_options[] = {
-{ "str", "set str", OFFSET(str), AV_OPT_TYPE_STRING, { .str = "i'm src 
default value" }, 0, 0, VE},
-{ "num", "set num", OFFSET(num), AV_OPT_TYPE_INT,{ .i64 = 1500100900 
},0, INT_MAX, VE},
-{ NULL },
-};
-
-static const AVClass dummy_v1_class = {
-.class_name = "dummy_v1_class",
-.item_name  = av_default_item_name,
-.option = dummy_options,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
-static const AVClass dummy_v2_class = {
-.class_name = "dummy_v2_class",
-.item_name  = av_default_item_name,
-.option = dummy_options,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
-/* codec with options */
-static AVCodec dummy_v1_encoder = {
-.name = "dummy_v1_codec",
-.type = AVMEDIA_TYPE_VIDEO,
-.id   = AV_CODEC_ID_NONE - 1,
-.encode2  = dummy_encode,
-.init = dummy_init,
-.close= dummy_close,
-.priv_class   = &dummy_v1_class,
-.priv_data_size   = sizeof(Dummy12Context),
-};
-
-/* codec with options, different class */
-static AVCodec dummy_v2_encoder = {
-.name = "dummy_v2_codec",
-.type = AVMEDIA_TYPE_VIDEO,
-.id   = AV_CODEC_ID_NONE - 2,
-.encode2  = dummy_encode,
-.init = dummy_init,
-.close= dummy_close,
-.priv_class   = &dummy_v2_class,
-.priv_data_size   = sizeof(Dummy12Context),
-};
-
-/* codec with priv data, but no class */
-static AVCodec dummy_v3_encoder = {
-.name = "dummy_v3_codec",
-.type = AVMEDIA_TYPE_VIDEO,
-.id   = AV_CODEC_ID_NONE - 3,
-.encode2  = dummy_encode,
-.init = dummy_init,
-.close= dummy_close,
-.priv_data_size   = sizeof(Dummy3Context),
-};
-
-/* codec without priv data */
-static AVCodec dummy_v4_encoder = {
-.name = "dummy_v4_codec",
-.type = AVMEDIA_TYPE_VIDEO,
-.id  

[FFmpeg-devel] [PATCH 3/5] tests/api-flac-test: convert to new encoding/decoding API

2021-02-24 Thread Anton Khirnov
---
 tests/api/api-flac-test.c | 40 +--
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 7c96a4d99e..3d83c56987 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -113,7 +113,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 uint8_t *raw_in = NULL, *raw_out = NULL;
 int in_offset = 0, out_offset = 0;
 int result = 0;
-int got_output = 0;
 int i = 0;
 int in_frame_bytes, out_frame_bytes;
 
@@ -167,25 +166,40 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 }
 memcpy(raw_in + in_offset, in_frame->data[0], in_frame_bytes);
 in_offset += in_frame_bytes;
-result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, 
&got_output);
+result = avcodec_send_frame(enc_ctx, in_frame);
 if (result < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
+av_log(NULL, AV_LOG_ERROR, "Error submitting a frame for 
encoding\n");
 return result;
 }
 
-/* if we get an encoded packet, feed it straight to the decoder */
-if (got_output) {
-result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, 
&enc_pkt);
+while (result >= 0) {
+result = avcodec_receive_packet(enc_ctx, &enc_pkt);
+if (result == AVERROR(EAGAIN))
+break;
+else if (result < 0 && result != AVERROR_EOF) {
+av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
+return result;
+}
+
+/* if we get an encoded packet, feed it straight to the decoder */
+result = avcodec_send_packet(dec_ctx, &enc_pkt);
+av_packet_unref(&enc_pkt);
 if (result < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n");
+av_log(NULL, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
 return result;
 }
 
-if (got_output) {
-if (result != enc_pkt.size) {
-av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a 
packet, it is allowed to do so -- need to update this test\n");
-return AVERROR_UNKNOWN;
-}
+result = avcodec_receive_frame(dec_ctx, out_frame);
+if (result == AVERROR(EAGAIN)) {
+result = 0;
+continue;
+} else if (result == AVERROR(EOF)) {
+result = 0;
+break;
+} else if (result < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n");
+return result;
+}
 
 if (in_frame->nb_samples != out_frame->nb_samples) {
 av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different number of samples\n");
@@ -208,9 +222,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 }
 memcpy(raw_out + out_offset, out_frame->data[0], 
out_frame_bytes);
 out_offset += out_frame_bytes;
-}
 }
-av_packet_unref(&enc_pkt);
 }
 
 if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_AUDIO_FRAMES) != 
0) {
-- 
2.28.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/5] tests/api-flac-test: reindent

2021-02-24 Thread Anton Khirnov
---
 tests/api/api-flac-test.c | 42 +++
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 3d83c56987..b67c3d7363 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -201,27 +201,27 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 return result;
 }
 
-if (in_frame->nb_samples != out_frame->nb_samples) {
-av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different number of samples\n");
-return AVERROR_UNKNOWN;
-}
-
-if (in_frame->channel_layout != out_frame->channel_layout) {
-av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different channel layout\n");
-return AVERROR_UNKNOWN;
-}
-
-if (in_frame->format != out_frame->format) {
-av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different sample format\n");
-return AVERROR_UNKNOWN;
-}
-out_frame_bytes = out_frame->nb_samples * out_frame->channels 
* sizeof(uint16_t);
-if (out_frame_bytes > out_frame->linesize[0]) {
-av_log(NULL, AV_LOG_ERROR, "Incorrect value of output 
frame linesize\n");
-return 1;
-}
-memcpy(raw_out + out_offset, out_frame->data[0], 
out_frame_bytes);
-out_offset += out_frame_bytes;
+if (in_frame->nb_samples != out_frame->nb_samples) {
+av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different number of samples\n");
+return AVERROR_UNKNOWN;
+}
+
+if (in_frame->channel_layout != out_frame->channel_layout) {
+av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different channel layout\n");
+return AVERROR_UNKNOWN;
+}
+
+if (in_frame->format != out_frame->format) {
+av_log(NULL, AV_LOG_ERROR, "Error frames before and after 
decoding has different sample format\n");
+return AVERROR_UNKNOWN;
+}
+out_frame_bytes = out_frame->nb_samples * out_frame->channels * 
sizeof(uint16_t);
+if (out_frame_bytes > out_frame->linesize[0]) {
+av_log(NULL, AV_LOG_ERROR, "Incorrect value of output frame 
linesize\n");
+return 1;
+}
+memcpy(raw_out + out_offset, out_frame->data[0], out_frame_bytes);
+out_offset += out_frame_bytes;
 }
 }
 
-- 
2.28.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/5] tests/api-flac-test: ensure the frame is writable before writing to it

2021-02-24 Thread Anton Khirnov
The encoder may keep a reference to frames that were sent to it, so the
caller cannot modify them without checking first.
---
 tests/api/api-flac-test.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 3fea3258f3..7c96a4d99e 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -154,6 +154,10 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 enc_pkt.data = NULL;
 enc_pkt.size = 0;
 
+result = av_frame_make_writable(in_frame);
+if (result < 0)
+return result;
+
 generate_raw_frame((uint16_t*)(in_frame->data[0]), i, 
enc_ctx->sample_rate,
enc_ctx->channels, enc_ctx->frame_size);
 in_frame_bytes = in_frame->nb_samples * in_frame->channels * 
sizeof(uint16_t);
-- 
2.28.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Handle AVID MJPEG streams directly in the MJPEG decoder.

2021-02-24 Thread Anton Khirnov
AVID streams - currently handled by the AVRN decoder - can be (depending
on extradata contents) either MJPEG or raw video. To decode the MJPEG
variant, the AVRN decoder currently instantiates a MJPEG decoder
internally and forwards decoded frames to the caller (possibly after
cropping them).

This is suboptimal, because the AVRN decoder does not forward all the
features of the internal MJPEG decoder, such as direct rendering.
Handling such forwarding in a full and generic manner would be quite
hard, so it is simpler to just handle those streams in the MJPEG decoder
directly.

The AVRN decoder, which now handles only the raw streams, can now be
marked as supporting direct rendering.

This also removes the last remaining internal use of the obsolete
decoding API.
---
Rebased against master
---
 configure   |  1 -
 libavcodec/avrndec.c| 71 +
 libavcodec/mjpegdec.c   | 11 +++
 libavcodec/version.h|  2 +-
 libavformat/avidec.c|  6 
 libavformat/isom_tags.c |  2 +-
 tests/fate/video.mak|  2 +-
 7 files changed, 21 insertions(+), 74 deletions(-)

diff --git a/configure b/configure
index 5250445325..d11942fced 100755
--- a/configure
+++ b/configure
@@ -2688,7 +2688,6 @@ atrac3p_decoder_select="mdct sinewin"
 atrac3pal_decoder_select="mdct sinewin"
 atrac9_decoder_select="mdct"
 av1_decoder_select="cbs_av1"
-avrn_decoder_select="mjpeg_decoder"
 bink_decoder_select="blockdsp hpeldsp"
 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index 9380d86885..26cf6b752c 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -24,8 +24,6 @@
 #include "libavutil/imgutils.h"
 
 typedef struct {
-AVCodecContext *mjpeg_avctx;
-int is_mjpeg;
 int interlace;
 int tff;
 } AVRnContext;
@@ -35,42 +33,6 @@ static av_cold int init(AVCodecContext *avctx)
 AVRnContext *a = avctx->priv_data;
 int ret;
 
-// Support "Resolution 1:1" for Avid AVI Codec
-a->is_mjpeg = avctx->extradata_size < 31 || memcmp(&avctx->extradata[28], 
"1:1", 3);
-
-if(!a->is_mjpeg && avctx->lowres) {
-av_log(avctx, AV_LOG_ERROR, "lowres is not possible with rawvideo\n");
-return AVERROR(EINVAL);
-}
-
-if(a->is_mjpeg) {
-const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
-AVDictionary *thread_opt = NULL;
-if (!codec) {
-av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
-return AVERROR_DECODER_NOT_FOUND;
-}
-
-a->mjpeg_avctx = avcodec_alloc_context3(codec);
-if (!a->mjpeg_avctx)
-return AVERROR(ENOMEM);
-
-av_dict_set(&thread_opt, "threads", "1", 0); // Is this needed ?
-a->mjpeg_avctx->refcounted_frames = 1;
-a->mjpeg_avctx->flags = avctx->flags;
-a->mjpeg_avctx->idct_algo = avctx->idct_algo;
-a->mjpeg_avctx->lowres = avctx->lowres;
-a->mjpeg_avctx->width = avctx->width;
-a->mjpeg_avctx->height = avctx->height;
-
-if ((ret = avcodec_open2(a->mjpeg_avctx, codec, &thread_opt)) < 0) {
-av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
-}
-av_dict_free(&thread_opt);
-
-return ret;
-}
-
 if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
 return ret;
 
@@ -87,15 +49,6 @@ static av_cold int init(AVCodecContext *avctx)
 return 0;
 }
 
-static av_cold int end(AVCodecContext *avctx)
-{
-AVRnContext *a = avctx->priv_data;
-
-avcodec_free_context(&a->mjpeg_avctx);
-
-return 0;
-}
-
 static int decode_frame(AVCodecContext *avctx, void *data,
 int *got_frame, AVPacket *avpkt)
 {
@@ -105,28 +58,6 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 int buf_size   = avpkt->size;
 int y, ret, true_height;
 
-if(a->is_mjpeg) {
-ret = avcodec_decode_video2(a->mjpeg_avctx, data, got_frame, avpkt);
-
-if (ret >= 0 && *got_frame && avctx->width <= p->width && 
avctx->height <= p->height) {
-int shift = p->height - avctx->height;
-int subsample_h, subsample_v;
-
-av_pix_fmt_get_chroma_sub_sample(p->format, &subsample_h, 
&subsample_v);
-
-p->data[0] += p->linesize[0] * shift;
-if (p->data[2]) {
-p->data[1] += p->linesize[1] * (shift>>subsample_v);
-p->data[2] += p->linesize[2] * (shift>>subsample_v);
-}
-
-p->width  = avctx->width;
-p->height = avctx->height;
-}
-avctx->pix_fmt = a->mjpeg_avctx->pix_fmt;
-return ret;
-}
-
 true_height= buf_size / (2*avctx->width);
 
 if(buf_size < 2*avctx->width * avctx->height) {
@@ -165,8 +96,8 @@ AVCodec ff_avrn_decoder = {
 .id = AV_CODEC_ID_AVRN,
 .priv_data_size =

[FFmpeg-devel] [PATCH] Handle AVID MJPEG streams directly in the MJPEG decoder.

2021-02-24 Thread Anton Khirnov
AVID streams - currently handled by the AVRN decoder - can be (depending
on extradata contents) either MJPEG or raw video. To decode the MJPEG
variant, the AVRN decoder currently instantiates a MJPEG decoder
internally and forwards decoded frames to the caller (possibly after
cropping them).

This is suboptimal, because the AVRN decoder does not forward all the
features of the internal MJPEG decoder, such as direct rendering.
Handling such forwarding in a full and generic manner would be quite
hard, so it is simpler to just handle those streams in the MJPEG decoder
directly.

The AVRN decoder, which now handles only the raw streams, can now be
marked as supporting direct rendering.

This also removes the last remaining internal use of the obsolete
decoding API.
---
And now without the missing isom tag change. Thanks to Andreas for noticing.
---
 configure   |  1 -
 libavcodec/avrndec.c| 71 +
 libavcodec/mjpegdec.c   | 11 +++
 libavcodec/version.h|  2 +-
 libavformat/avidec.c|  6 
 libavformat/isom_tags.c |  4 +--
 tests/fate/video.mak|  2 +-
 7 files changed, 22 insertions(+), 75 deletions(-)

diff --git a/configure b/configure
index 5250445325..d11942fced 100755
--- a/configure
+++ b/configure
@@ -2688,7 +2688,6 @@ atrac3p_decoder_select="mdct sinewin"
 atrac3pal_decoder_select="mdct sinewin"
 atrac9_decoder_select="mdct"
 av1_decoder_select="cbs_av1"
-avrn_decoder_select="mjpeg_decoder"
 bink_decoder_select="blockdsp hpeldsp"
 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index 9380d86885..26cf6b752c 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -24,8 +24,6 @@
 #include "libavutil/imgutils.h"
 
 typedef struct {
-AVCodecContext *mjpeg_avctx;
-int is_mjpeg;
 int interlace;
 int tff;
 } AVRnContext;
@@ -35,42 +33,6 @@ static av_cold int init(AVCodecContext *avctx)
 AVRnContext *a = avctx->priv_data;
 int ret;
 
-// Support "Resolution 1:1" for Avid AVI Codec
-a->is_mjpeg = avctx->extradata_size < 31 || memcmp(&avctx->extradata[28], 
"1:1", 3);
-
-if(!a->is_mjpeg && avctx->lowres) {
-av_log(avctx, AV_LOG_ERROR, "lowres is not possible with rawvideo\n");
-return AVERROR(EINVAL);
-}
-
-if(a->is_mjpeg) {
-const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
-AVDictionary *thread_opt = NULL;
-if (!codec) {
-av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
-return AVERROR_DECODER_NOT_FOUND;
-}
-
-a->mjpeg_avctx = avcodec_alloc_context3(codec);
-if (!a->mjpeg_avctx)
-return AVERROR(ENOMEM);
-
-av_dict_set(&thread_opt, "threads", "1", 0); // Is this needed ?
-a->mjpeg_avctx->refcounted_frames = 1;
-a->mjpeg_avctx->flags = avctx->flags;
-a->mjpeg_avctx->idct_algo = avctx->idct_algo;
-a->mjpeg_avctx->lowres = avctx->lowres;
-a->mjpeg_avctx->width = avctx->width;
-a->mjpeg_avctx->height = avctx->height;
-
-if ((ret = avcodec_open2(a->mjpeg_avctx, codec, &thread_opt)) < 0) {
-av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
-}
-av_dict_free(&thread_opt);
-
-return ret;
-}
-
 if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
 return ret;
 
@@ -87,15 +49,6 @@ static av_cold int init(AVCodecContext *avctx)
 return 0;
 }
 
-static av_cold int end(AVCodecContext *avctx)
-{
-AVRnContext *a = avctx->priv_data;
-
-avcodec_free_context(&a->mjpeg_avctx);
-
-return 0;
-}
-
 static int decode_frame(AVCodecContext *avctx, void *data,
 int *got_frame, AVPacket *avpkt)
 {
@@ -105,28 +58,6 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 int buf_size   = avpkt->size;
 int y, ret, true_height;
 
-if(a->is_mjpeg) {
-ret = avcodec_decode_video2(a->mjpeg_avctx, data, got_frame, avpkt);
-
-if (ret >= 0 && *got_frame && avctx->width <= p->width && 
avctx->height <= p->height) {
-int shift = p->height - avctx->height;
-int subsample_h, subsample_v;
-
-av_pix_fmt_get_chroma_sub_sample(p->format, &subsample_h, 
&subsample_v);
-
-p->data[0] += p->linesize[0] * shift;
-if (p->data[2]) {
-p->data[1] += p->linesize[1] * (shift>>subsample_v);
-p->data[2] += p->linesize[2] * (shift>>subsample_v);
-}
-
-p->width  = avctx->width;
-p->height = avctx->height;
-}
-avctx->pix_fmt = a->mjpeg_avctx->pix_fmt;
-return ret;
-}
-
 true_height= buf_size / (2*avctx->width);
 
 if(buf_size < 2*avctx->width * avctx->height) {
@@ -165,8 +96,8 @@ AVCodec ff_avrn_decoder = {
 .id

[FFmpeg-devel] [PATCH 3/3] libavformat/hls: correct indentation

2021-02-24 Thread Nachiket Tarate
Signed-off-by: Nachiket Tarate 
---
 libavformat/hls.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3cb3853c79..d612ebb185 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2028,23 +2028,23 @@ static int hls_read_header(AVFormatContext *s)
 break;
 }
 } else {
-pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
-pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? 
s->max_analyze_duration : 4 * AV_TIME_BASE;
-pls->ctx->interrupt_callback = s->interrupt_callback;
-url = av_strdup(pls->segments[0]->url);
-ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0);
-if (ret < 0) {
-/* Free the ctx - it isn't initialized properly at this point,
- * so avformat_close_input shouldn't be called. If
- * avformat_open_input fails below, it frees and zeros the
- * context, so it doesn't need any special treatment like this. */
-av_log(s, AV_LOG_ERROR, "Error when loading first segment '%s'\n", 
url);
-avformat_free_context(pls->ctx);
-pls->ctx = NULL;
+pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
+pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? 
s->max_analyze_duration : 4 * AV_TIME_BASE;
+pls->ctx->interrupt_callback = s->interrupt_callback;
+url = av_strdup(pls->segments[0]->url);
+ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0);
+if (ret < 0) {
+/* Free the ctx - it isn't initialized properly at this point,
+* so avformat_close_input shouldn't be called. If
+* avformat_open_input fails below, it frees and zeros the
+* context, so it doesn't need any special treatment like this. 
*/
+av_log(s, AV_LOG_ERROR, "Error when loading first segment 
'%s'\n", url);
+avformat_free_context(pls->ctx);
+pls->ctx = NULL;
+av_free(url);
+goto fail;
+}
 av_free(url);
-goto fail;
-}
-av_free(url);
 }
 
 if (seg && seg->key_type == KEY_SAMPLE_AES) {
@@ -2096,7 +2096,7 @@ static int hls_read_header(AVFormatContext *s)
 pls->ctx->nb_streams == 1)
 ret = ff_hls_parse_audio_setup_info(pls->ctx->streams[0], 
&pls->audio_setup_info);
 else
-ret = avformat_find_stream_info(pls->ctx, NULL);
+ret = avformat_find_stream_info(pls->ctx, NULL);
 
 if (ret < 0)
 goto fail;
-- 
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 1/3] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header

2021-02-24 Thread Nachiket Tarate
These will be used by HLS demuxer in case of SAMPLE-AES decryption.

Signed-off-by: Nachiket Tarate 
---
 libavcodec/adts_header.c |  1 +
 libavcodec/adts_header.h | 14 ++
 libavcodec/adts_parser.c | 28 
 3 files changed, 43 insertions(+)

diff --git a/libavcodec/adts_header.c b/libavcodec/adts_header.c
index 0889820f8a..e4454529c4 100644
--- a/libavcodec/adts_header.c
+++ b/libavcodec/adts_header.c
@@ -66,6 +66,7 @@ int ff_adts_header_parse(GetBitContext *gbc, 
AACADTSHeaderInfo *hdr)
 hdr->sample_rate= avpriv_mpeg4audio_sample_rates[sr];
 hdr->samples= (rdb + 1) * 1024;
 hdr->bit_rate   = size * 8 * hdr->sample_rate / hdr->samples;
+hdr->frame_length   = size;
 
 return size;
 }
diff --git a/libavcodec/adts_header.h b/libavcodec/adts_header.h
index f615f6a9f9..9ecd67fb5b 100644
--- a/libavcodec/adts_header.h
+++ b/libavcodec/adts_header.h
@@ -34,6 +34,7 @@ typedef struct AACADTSHeaderInfo {
 uint8_t  sampling_index;
 uint8_t  chan_config;
 uint8_t  num_aac_frames;
+uint32_t frame_length;
 } AACADTSHeaderInfo;
 
 /**
@@ -47,4 +48,17 @@ typedef struct AACADTSHeaderInfo {
  */
 int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
 
+/**
+ * Parse the ADTS frame header contained in the buffer, which is
+ * the first 54 bits.
+ * @param[in]  buf  Pointer to buffer containing the first 54 bits of the 
frame.
+ * @param[in]  size Size of buffer containing the first 54 bits of the frame.
+ * @param[out] phdr Pointer to pointer to struct AACADTSHeaderInfo for which
+ * memory is allocated and header info is written into it.
+ * @return Returns 0 on success, -1 if there is a sync word mismatch,
+ * -2 if the version element is invalid, -3 if the sample rate
+ * element is invalid, or -4 if the bit rate element is invalid.
+ */
+int avpriv_adts_header_parse(AACADTSHeaderInfo **phdr, const uint8_t *buf, 
size_t size);
+
 #endif /* AVCODEC_ADTS_HEADER_H */
diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c
index 5c9f8ff6f2..7df714e227 100644
--- a/libavcodec/adts_parser.c
+++ b/libavcodec/adts_parser.c
@@ -42,3 +42,31 @@ int av_adts_header_parse(const uint8_t *buf, uint32_t 
*samples, uint8_t *frames)
 return AVERROR(ENOSYS);
 #endif
 }
+
+int avpriv_adts_header_parse(AACADTSHeaderInfo **phdr, const uint8_t *buf, 
size_t size)
+{
+#if CONFIG_ADTS_HEADER
+int ret = 0;
+GetBitContext gb;
+
+if (size < AV_AAC_ADTS_HEADER_SIZE)
+return AVERROR_INVALIDDATA;
+
+if (!*phdr)
+*phdr = av_mallocz(sizeof(AACADTSHeaderInfo));
+if (!*phdr)
+return AVERROR(ENOMEM);
+
+ret = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
+if (ret < 0)
+return ret;
+
+ret = ff_adts_header_parse(&gb, *phdr);
+if (ret < 0)
+return ret;
+
+return 0;
+#else
+return AVERROR(ENOSYS);
+#endif
+}
-- 
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 01/15] avformat/movenc: Remove always true check

2021-02-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 545b0885ae..cdfcbd3d76 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6395,7 +6395,6 @@ static int mov_init(AVFormatContext *s)
 /* Default mode == MP4 */
 mov->mode = MODE_MP4;
 
-if (s->oformat) {
 if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
 else if (!strcmp("3g2", s->oformat->name)) mov->mode = 
MODE_3GP|MODE_3G2;
 else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
@@ -6403,7 +6402,6 @@ static int mov_init(AVFormatContext *s)
 else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
 else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
 else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V;
-}
 
 if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
 mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 02/15] avformat/movenc: Don't check for disabled muxers

2021-02-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
Given that the name of every possible muxer here has a strlen of three
or four one could even replace the strcmp by
AV_RN32(s->oformat->name) == AV_RN32(#muxer).

 libavformat/movenc.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index cdfcbd3d76..cf0e35dd33 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6395,13 +6395,15 @@ static int mov_init(AVFormatContext *s)
 /* Default mode == MP4 */
 mov->mode = MODE_MP4;
 
-if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
-else if (!strcmp("3g2", s->oformat->name)) mov->mode = 
MODE_3GP|MODE_3G2;
-else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
-else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
-else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
-else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
-else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V;
+#define IS_MODE(muxer, config) (CONFIG_ ## config ## _MUXER && !strcmp(#muxer, 
s->oformat->name))
+if  (IS_MODE(3gp,   TGP)) mov->mode = MODE_3GP;
+else if (IS_MODE(3g2,   TG2)) mov->mode = MODE_3GP|MODE_3G2;
+else if (IS_MODE(mov,   MOV)) mov->mode = MODE_MOV;
+else if (IS_MODE(psp,   PSP)) mov->mode = MODE_PSP;
+else if (IS_MODE(ipod, IPOD)) mov->mode = MODE_IPOD;
+else if (IS_MODE(ismv, ISMV)) mov->mode = MODE_ISM;
+else if (IS_MODE(f4v,   F4V)) mov->mode = MODE_F4V;
+#undef IS_MODE
 
 if (mov->flags & FF_MOV_FLAG_DELAY_MOOV)
 mov->flags |= FF_MOV_FLAG_EMPTY_MOOV;
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 03/15] fftools/ffmpeg, ffplay: Don't set refcounted_frames

2021-02-24 Thread Andreas Rheinhardt
It only affects the old and deprecated avcodec_decode_(video2|audio4)
API which is no longer used here.

Signed-off-by: Andreas Rheinhardt 
---
I am surprised that no one found this before me. Is it because there was
no -Wdeprecated-declarations warning?

 fftools/ffmpeg.c | 1 -
 fftools/ffplay.c | 2 --
 2 files changed, 3 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index add5a3e505..abf35150bd 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2957,7 +2957,6 @@ static int init_input_stream(int ist_index, char *error, 
int error_len)
 ist->dec_ctx->thread_safe_callbacks = 1;
 #endif
 
-av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0);
 if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
(ist->decoding_needed & DECODING_FOR_OST)) {
 av_dict_set(&ist->decoder_opts, "compute_edt", "1", 
AV_DICT_DONT_OVERWRITE);
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index b9a30cdb11..ac0885b84e 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2628,8 +2628,6 @@ static int stream_component_open(VideoState *is, int 
stream_index)
 av_dict_set(&opts, "threads", "auto", 0);
 if (stream_lowres)
 av_dict_set_int(&opts, "lowres", stream_lowres, 0);
-if (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == 
AVMEDIA_TYPE_AUDIO)
-av_dict_set(&opts, "refcounted_frames", "1", 0);
 if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) {
 goto fail;
 }
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 04/15] avformat/movenc: Only check for timecodes if they are used

2021-02-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenc.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index cf0e35dd33..8ac5c317b4 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6387,7 +6387,6 @@ static int 
mov_create_dvd_sub_decoder_specific_info(MOVTrack *track,
 static int mov_init(AVFormatContext *s)
 {
 MOVMuxContext *mov = s->priv_data;
-AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 
0);
 int i, ret;
 
 mov->fc = s;
@@ -6505,6 +6504,9 @@ static int mov_init(AVFormatContext *s)
 
 if (   mov->write_tmcd == -1 && (mov->mode == MODE_MOV || mov->mode == 
MODE_MP4)
 || mov->write_tmcd == 1) {
+AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode",
+NULL, 0);
+
 /* +1 tmcd track for each video stream with a timecode */
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
@@ -6725,7 +6727,6 @@ static int mov_write_header(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 MOVMuxContext *mov = s->priv_data;
-AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", 
NULL, 0);
 int i, ret, hint_track = 0, tmcd_track = 0, nb_tracks = s->nb_streams;
 
 if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
@@ -6824,6 +6825,8 @@ static int mov_write_header(AVFormatContext *s)
 }
 
 if (mov->nb_meta_tmcd) {
+const AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata,
+  "timecode", 
NULL, 0);
 /* Initialize the tmcd tracks */
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 05/15] avformat/pcm(dec|enc): Don't include disabled (de)muxers

2021-02-24 Thread Andreas Rheinhardt
Also make the macro used for the demuxers spec-compliant. The earlier
macro was not, because the ... argument of a variadic macro must not be
left out. GCC and Clang warn about this when using -pedantic.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/pcmdec.c | 102 ---
 libavformat/pcmenc.c |  95 +---
 2 files changed, 68 insertions(+), 129 deletions(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 9895af03a4..e65b535665 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -104,7 +104,8 @@ static const AVOption pcm_options[] = {
 { NULL },
 };
 
-#define PCMDEF(name_, long_name_, ext, codec, ...)  \
+#define PCMDEF_0(name_, long_name_, ext, codec, ...)
+#define PCMDEF_1(name_, long_name_, ext, codec, ...)\
 static const AVClass name_ ## _demuxer_class = {\
 .class_name = #name_ " demuxer",\
 .item_name  = av_default_item_name, \
@@ -124,70 +125,40 @@ AVInputFormat ff_pcm_ ## name_ ## _demuxer = {
  \
 .priv_class = &name_ ## _demuxer_class, \
 __VA_ARGS__ \
 };
-
-PCMDEF(f64be, "PCM 64-bit floating-point big-endian",
-   NULL, AV_CODEC_ID_PCM_F64BE)
-
-PCMDEF(f64le, "PCM 64-bit floating-point little-endian",
-   NULL, AV_CODEC_ID_PCM_F64LE)
-
-PCMDEF(f32be, "PCM 32-bit floating-point big-endian",
-   NULL, AV_CODEC_ID_PCM_F32BE)
-
-PCMDEF(f32le, "PCM 32-bit floating-point little-endian",
-   NULL, AV_CODEC_ID_PCM_F32LE)
-
-PCMDEF(s32be, "PCM signed 32-bit big-endian",
-   NULL, AV_CODEC_ID_PCM_S32BE)
-
-PCMDEF(s32le, "PCM signed 32-bit little-endian",
-   NULL, AV_CODEC_ID_PCM_S32LE)
-
-PCMDEF(s24be, "PCM signed 24-bit big-endian",
-   NULL, AV_CODEC_ID_PCM_S24BE)
-
-PCMDEF(s24le, "PCM signed 24-bit little-endian",
-   NULL, AV_CODEC_ID_PCM_S24LE)
-
-PCMDEF(s16be, "PCM signed 16-bit big-endian",
-   AV_NE("sw", NULL), AV_CODEC_ID_PCM_S16BE, .mime_type = "audio/L16")
-
-PCMDEF(s16le, "PCM signed 16-bit little-endian",
-   AV_NE(NULL, "sw"), AV_CODEC_ID_PCM_S16LE)
-
-PCMDEF(s8, "PCM signed 8-bit",
-   "sb", AV_CODEC_ID_PCM_S8)
-
-PCMDEF(u32be, "PCM unsigned 32-bit big-endian",
-   NULL, AV_CODEC_ID_PCM_U32BE)
-
-PCMDEF(u32le, "PCM unsigned 32-bit little-endian",
-   NULL, AV_CODEC_ID_PCM_U32LE)
-
-PCMDEF(u24be, "PCM unsigned 24-bit big-endian",
-   NULL, AV_CODEC_ID_PCM_U24BE)
-
-PCMDEF(u24le, "PCM unsigned 24-bit little-endian",
-   NULL, AV_CODEC_ID_PCM_U24LE)
-
-PCMDEF(u16be, "PCM unsigned 16-bit big-endian",
-   AV_NE("uw", NULL), AV_CODEC_ID_PCM_U16BE)
-
-PCMDEF(u16le, "PCM unsigned 16-bit little-endian",
-   AV_NE(NULL, "uw"), AV_CODEC_ID_PCM_U16LE)
-
-PCMDEF(u8, "PCM unsigned 8-bit",
-   "ub", AV_CODEC_ID_PCM_U8)
-
-PCMDEF(alaw, "PCM A-law",
-   "al", AV_CODEC_ID_PCM_ALAW)
-
-PCMDEF(mulaw, "PCM mu-law",
-   "ul", AV_CODEC_ID_PCM_MULAW)
-
-PCMDEF(vidc, "PCM Archimedes VIDC",
-   NULL, AV_CODEC_ID_PCM_VIDC)
-
+#define PCMDEF_2(name, long_name, ext, codec, enabled, ...) \
+PCMDEF_ ## enabled(name, long_name, ext, codec, __VA_ARGS__)
+#define PCMDEF_3(name, long_name, ext, codec, config, ...)  \
+PCMDEF_2(name, long_name, ext, codec, config,   __VA_ARGS__)
+#define PCMDEF_EXT(name, long_name, ext, uppercase, ...)\
+PCMDEF_3(name, long_name, ext, AV_CODEC_ID_PCM_ ## uppercase, \
+ CONFIG_PCM_ ## uppercase ## _DEMUXER,  __VA_ARGS__)
+#define PCMDEF(name, long_name, ext, uppercase) \
+PCMDEF_EXT(name, long_name, ext, uppercase, )
+
+PCMDEF(f64be, "PCM 64-bit floating-point big-endian",   NULL, F64BE)
+PCMDEF(f64le, "PCM 64-bit floating-point little-endian",NULL, F64LE)
+PCMDEF(f32be, "PCM 32-bit floating-point big-endian",   NULL, F32BE)
+PCMDEF(f32le, "PCM 32-bit floating-point little-endian",NULL, F32LE)
+PCMDEF(s32be, "PCM signed 32-bit big-endian",   NULL, S32BE)
+PCMDEF(s32le, "PCM signed 32-bit little-endian",NULL, S32LE)
+PCMDEF(s24be, "PCM signed 24-bit big-endian",   NULL, S24BE)
+PCMDEF(s24le, "PCM signed 24-bit little-endian",NULL, S24LE)
+PCMDEF_EXT(s16be, "PCM signed 16-bit big-endian",
+   AV_NE("sw", NULL), S16BE, .mime_type = "audio/L16")
+PCMDEF(s16le, "PCM signed 16-bit little-endian",   AV_NE(NULL, "sw"), S16LE)
+PCMDEF(s8,"PCM signed 8-bit",   "sb",S8)
+PCMDEF(u32be, "PCM unsigned 32-bit big-endian", NULL, U32BE)
+PCMDEF(u32le, "PCM unsigned 32-bit little-endian",  NULL, U32LE)
+PCMDEF(u24be, "PCM unsigned 24-bit big-endian", NULL, U24BE)
+PCMDEF(u24le, "PCM unsigned 24-bit little-endian",  NULL, U24LE)
+PCMDEF(u16be, "PCM unsigned 16-bit big-endian",AV_NE("uw", NULL), U16BE)
+PCMDEF(u16le, "PCM u

[FFmpeg-devel] [PATCH 06/15] avformat/pcmdec: Fix NULL + 1

2021-02-24 Thread Andreas Rheinhardt
It is undefined behaviour.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/pcmdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index e65b535665..395d9ecf92 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -57,8 +57,9 @@ static int pcm_read_header(AVFormatContext *s)
 len = strlen(mime_type);
 while (options < mime_type + len) {
 options = strstr(options, ";");
-if (!options++)
+if (!options)
 break;
+options++;
 if (!rate)
 sscanf(options, " rate=%d", &rate);
 if (!channels)
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 07/15] avformat/pcmdec: Simplify parsing MIME type

2021-02-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/pcmdec.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 395d9ecf92..cd3e7b2e8f 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
 #include "pcm.h"
@@ -51,14 +52,9 @@ static int pcm_read_header(AVFormatContext *s)
 av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
 if (mime_type && s->iformat->mime_type) {
 int rate = 0, channels = 0, little_endian = 0;
-size_t len = strlen(s->iformat->mime_type);
-if (!av_strncasecmp(s->iformat->mime_type, mime_type, len)) { /* 
audio/L16 */
-uint8_t *options = mime_type + len;
-len = strlen(mime_type);
-while (options < mime_type + len) {
-options = strstr(options, ";");
-if (!options)
-break;
+const char *options;
+if (av_stristart(mime_type, s->iformat->mime_type, &options)) { /* 
audio/L16 */
+while (options = strchr(options, ';')) {
 options++;
 if (!rate)
 sscanf(options, " rate=%d", &rate);
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 08/15] avformat/pcmdec: Beautify pcm_read_header

2021-02-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/pcmdec.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index cd3e7b2e8f..9b552936ac 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -36,18 +36,19 @@ typedef struct PCMAudioDemuxerContext {
 static int pcm_read_header(AVFormatContext *s)
 {
 PCMAudioDemuxerContext *s1 = s->priv_data;
+AVCodecParameters *par;
 AVStream *st;
 uint8_t *mime_type = NULL;
 
 st = avformat_new_stream(s, NULL);
 if (!st)
 return AVERROR(ENOMEM);
+par = st->codecpar;
 
-
-st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
-st->codecpar->codec_id= s->iformat->raw_codec_id;
-st->codecpar->sample_rate = s1->sample_rate;
-st->codecpar->channels= s1->channels;
+par->codec_type  = AVMEDIA_TYPE_AUDIO;
+par->codec_id= s->iformat->raw_codec_id;
+par->sample_rate = s1->sample_rate;
+par->channels= s1->channels;
 
 av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
 if (mime_type && s->iformat->mime_type) {
@@ -61,7 +62,7 @@ static int pcm_read_header(AVFormatContext *s)
 if (!channels)
 sscanf(options, " channels=%d", &channels);
 if (!little_endian) {
- char val[14]; /* sizeof("little-endian") == 14 */
+ char val[sizeof("little-endian")];
  if (sscanf(options, " endianness=%13s", val) == 1) {
  little_endian = strcmp(val, "little-endian") == 0;
  }
@@ -74,24 +75,22 @@ static int pcm_read_header(AVFormatContext *s)
 av_freep(&mime_type);
 return AVERROR_INVALIDDATA;
 }
-st->codecpar->sample_rate = rate;
+par->sample_rate = rate;
 if (channels > 0)
-st->codecpar->channels = channels;
+par->channels = channels;
 if (little_endian)
-st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+par->codec_id = AV_CODEC_ID_PCM_S16LE;
 }
 }
 av_freep(&mime_type);
 
-st->codecpar->bits_per_coded_sample =
-av_get_bits_per_sample(st->codecpar->codec_id);
+par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
 
-av_assert0(st->codecpar->bits_per_coded_sample > 0);
+av_assert0(par->bits_per_coded_sample > 0);
 
-st->codecpar->block_align =
-st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
+par->block_align = par->bits_per_coded_sample * par->channels / 8;
 
-avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
+avpriv_set_pts_info(st, 64, 1, par->sample_rate);
 return 0;
 }
 
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 09/15] avutil/pixdesc: Use av_strstart where appropriate

2021-02-24 Thread Andreas Rheinhardt
It makes the intent clearer and allows to avoid calculating the strlen
separately.

Signed-off-by: Andreas Rheinhardt 
---
 libavutil/pixdesc.c | 33 +++--
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 8274713226..2a919461a5 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2702,11 +2702,13 @@ static int get_color_type(const AVPixFmtDescriptor 
*desc) {
 if(desc->nb_components == 1 || desc->nb_components == 2)
 return FF_COLOR_GRAY;
 
-if(desc->name && !strncmp(desc->name, "yuvj", 4))
-return FF_COLOR_YUV_JPEG;
+if (desc->name) {
+if (av_strstart(desc->name, "yuvj", NULL))
+return FF_COLOR_YUV_JPEG;
 
-if(desc->name && !strncmp(desc->name, "xyz", 3))
-return FF_COLOR_XYZ;
+if (av_strstart(desc->name, "xyz", NULL))
+return FF_COLOR_XYZ;
+}
 
 if(desc->flags & AV_PIX_FMT_FLAG_RGB)
 return  FF_COLOR_RGB;
@@ -2907,8 +2909,7 @@ int av_color_range_from_name(const char *name)
 int i;
 
 for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
-size_t len = strlen(color_range_names[i]);
-if (!strncmp(color_range_names[i], name, len))
+if (av_strstart(name, color_range_names[i], NULL))
 return i;
 }
 
@@ -2926,13 +2927,10 @@ int av_color_primaries_from_name(const char *name)
 int i;
 
 for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) {
-size_t len;
-
 if (!color_primaries_names[i])
 continue;
 
-len = strlen(color_primaries_names[i]);
-if (!strncmp(color_primaries_names[i], name, len))
+if (av_strstart(name, color_primaries_names[i], NULL))
 return i;
 }
 
@@ -2950,13 +2948,10 @@ int av_color_transfer_from_name(const char *name)
 int i;
 
 for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) {
-size_t len;
-
 if (!color_transfer_names[i])
 continue;
 
-len = strlen(color_transfer_names[i]);
-if (!strncmp(color_transfer_names[i], name, len))
+if (av_strstart(name, color_transfer_names[i], NULL))
 return i;
 }
 
@@ -2974,13 +2969,10 @@ int av_color_space_from_name(const char *name)
 int i;
 
 for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) {
-size_t len;
-
 if (!color_space_names[i])
 continue;
 
-len = strlen(color_space_names[i]);
-if (!strncmp(color_space_names[i], name, len))
+if (av_strstart(name, color_space_names[i], NULL))
 return i;
 }
 
@@ -2998,13 +2990,10 @@ int av_chroma_location_from_name(const char *name)
 int i;
 
 for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) {
-size_t len;
-
 if (!chroma_location_names[i])
 continue;
 
-len = strlen(chroma_location_names[i]);
-if (!strncmp(chroma_location_names[i], name, len))
+if (av_strstart(name, chroma_location_names[i], NULL))
 return i;
 }
 
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 10/15] avutil/stereo3d: Use av_strstart instead of strncmp

2021-02-24 Thread Andreas Rheinhardt
It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt 
---
 libavutil/stereo3d.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index 6edcdb1796..279fcc1ff3 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
 #include 
 
+#include "avstring.h"
 #include "common.h"
 #include "mem.h"
 #include "stereo3d.h"
@@ -67,8 +67,7 @@ int av_stereo3d_from_name(const char *name)
 int i;
 
 for (i = 0; i < FF_ARRAY_ELEMS(stereo3d_type_names); i++) {
-size_t len = strlen(stereo3d_type_names[i]);
-if (!strncmp(stereo3d_type_names[i], name, len))
+if (av_strstart(name, stereo3d_type_names[i], NULL))
 return i;
 }
 
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 11/15] avutil/spherical: Use av_strstart instead of strncmp

2021-02-24 Thread Andreas Rheinhardt
It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt 
---
 libavutil/spherical.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index 4a7f3e49ca..ed66344a2f 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "avstring.h"
 #include "mem.h"
 #include "spherical.h"
 
@@ -70,8 +71,7 @@ int av_spherical_from_name(const char *name)
 int i;
 
 for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
-size_t len = strlen(spherical_projection_names[i]);
-if (!strncmp(spherical_projection_names[i], name, len))
+if (av_strstart(name, spherical_projection_names[i], NULL))
 return i;
 }
 
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 12/15] fftools/cmdutils: Use av_strstart instead of strncmp

2021-02-24 Thread Andreas Rheinhardt
It makes the intent clearer and avoids searching for a delimiter
in advance.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/cmdutils.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 4eb68d2201..fe253d10a4 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -215,11 +215,9 @@ void show_help_children(const AVClass *class, int flags)
 
 static const OptionDef *find_option(const OptionDef *po, const char *name)
 {
-const char *p = strchr(name, ':');
-int len = p ? p - name : strlen(name);
-
 while (po->name) {
-if (!strncmp(name, po->name, len) && strlen(po->name) == len)
+const char *end;
+if (av_strstart(name, po->name, &end) && (!*end || *end == ':'))
 break;
 po++;
 }
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 13/15] avformat/avio: Use av_strstart instead of strncmp

2021-02-24 Thread Andreas Rheinhardt
It makes the intent clearer and avoids calculating the length
in advance.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/avio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index fbe07e44bc..8011482e76 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -114,11 +114,10 @@ static int url_alloc_for_protocol(URLContext **puc, const 
URLProtocol *up,
 goto fail;
 }
 if (up->priv_data_class) {
-int proto_len= strlen(up->name);
-char *start = strchr(uc->filename, ',');
+char *start;
 *(const AVClass **)uc->priv_data = up->priv_data_class;
 av_opt_set_defaults(uc->priv_data);
-if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + 
proto_len == start){
+if (av_strstart(uc->filename, up->name, (const char**)&start) && 
*start == ',') {
 int ret= 0;
 char *p= start;
 char sep= *++p;
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 14/15] avformat/matroskadec: Use av_strstart instead of strncmp

2021-02-24 Thread Andreas Rheinhardt
It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskadec.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1f96b49fc4..c03cd8bd09 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2470,8 +2470,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
  encodings[0].compression.settings.size);
 
 for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) {
-if (!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
- strlen(ff_mkv_codec_tags[j].str))) {
+if (av_strstart(track->codec_id, ff_mkv_codec_tags[j].str, NULL)) {
 codec_id = ff_mkv_codec_tags[j].id;
 break;
 }
@@ -2986,8 +2985,7 @@ static int matroska_read_header(AVFormatContext *s)
 st->codecpar->codec_id   = AV_CODEC_ID_NONE;
 
 for (i = 0; mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
-if (!strncmp(mkv_image_mime_tags[i].str, attachments[j].mime,
- strlen(mkv_image_mime_tags[i].str))) {
+if (av_strstart(attachments[j].mime, 
mkv_image_mime_tags[i].str, NULL)) {
 st->codecpar->codec_id = mkv_image_mime_tags[i].id;
 break;
 }
@@ -3016,8 +3014,7 @@ static int matroska_read_header(AVFormatContext *s)
attachments[j].bin.size);
 
 for (i = 0; mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
-if (!strncmp(mkv_mime_tags[i].str, attachments[j].mime,
-strlen(mkv_mime_tags[i].str))) {
+if (av_strstart(attachments[j].mime, mkv_mime_tags[i].str, 
NULL)) {
 st->codecpar->codec_id = mkv_mime_tags[i].id;
 break;
 }
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 15/15] avformt/webmdashenc: Use av_strstart instead of strncmp

2021-02-24 Thread Andreas Rheinhardt
It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/webmdashenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index 04f8cbe39d..332d0466e1 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -133,7 +133,7 @@ static int subsegment_alignment(AVFormatContext *s, const 
AdaptationSet *as)
 for (i = 1; i < as->nb_streams; i++) {
 AVDictionaryEntry *ts = 
av_dict_get(s->streams[as->streams[i]]->metadata,
 CUE_TIMESTAMPS, NULL, 0);
-if (!ts || strncmp(gold->value, ts->value, strlen(gold->value))) 
return 0;
+if (!ts || !av_strstart(ts->value, gold->value, NULL)) return 0;
 }
 return 1;
 }
@@ -152,7 +152,7 @@ static int bitstream_switching(AVFormatContext *s, const 
AdaptationSet *as)
TRACK_NUMBER, NULL, 0);
 AVCodecParameters *par = st->codecpar;
 if (!track_num ||
-strncmp(gold_track_num->value, track_num->value, 
strlen(gold_track_num->value)) ||
+!av_strstart(track_num->value, gold_track_num->value, NULL) ||
 gold_par->codec_id != par->codec_id ||
 gold_par->extradata_size != par->extradata_size ||
 memcmp(gold_par->extradata, par->extradata, par->extradata_size)) {
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] libavformat/hls: add support for decryption of HLS streams in MPEG-TS format protected using SAMPLE-AES encryption

2021-02-24 Thread Nachiket Tarate
Apple HTTP Live Streaming Sample Encryption:

https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption

Signed-off-by: Nachiket Tarate 
---
 libavformat/Makefile |   2 +-
 libavformat/hls.c| 105 --
 libavformat/hls_sample_aes.c | 391 +++
 libavformat/hls_sample_aes.h |  66 ++
 libavformat/mpegts.c |  12 ++
 5 files changed, 562 insertions(+), 14 deletions(-)
 create mode 100644 libavformat/hls_sample_aes.c
 create mode 100644 libavformat/hls_sample_aes.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index fcb39ce133..62627d50a6 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -236,7 +236,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
-OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
+OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_aes.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
 OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
diff --git a/libavformat/hls.c b/libavformat/hls.c
index af2468ad9b..3cb3853c79 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2,6 +2,7 @@
  * Apple HTTP Live Streaming demuxer
  * Copyright (c) 2010 Martin Storsjo
  * Copyright (c) 2013 Anssi Hannula
+ * Copyright (c) 2021 Nachiket Tarate
  *
  * This file is part of FFmpeg.
  *
@@ -39,6 +40,8 @@
 #include "avio_internal.h"
 #include "id3v2.h"
 
+#include "hls_sample_aes.h"
+
 #define INITIAL_BUFFER_SIZE 32768
 
 #define MAX_FIELD_LEN 64
@@ -145,6 +148,10 @@ struct playlist {
 int id3_changed; /* ID3 tag data has changed at some point */
 ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer is 
opened */
 
+/* Used in case of SAMPLE-AES encryption method */
+HLSAudioSetupInfo audio_setup_info;
+HLSCryptoContext  crypto_ctx;
+
 int64_t seek_timestamp;
 int seek_flags;
 int seek_stream_index; /* into subdemuxer stream array */
@@ -266,6 +273,8 @@ static void free_playlist_list(HLSContext *c)
 pls->ctx->pb = NULL;
 avformat_close_input(&pls->ctx);
 }
+if (pls->crypto_ctx.aes_ctx)
+ av_free(pls->crypto_ctx.aes_ctx);
 av_free(pls);
 }
 av_freep(&c->playlists);
@@ -994,7 +1003,10 @@ fail:
 
 static struct segment *current_segment(struct playlist *pls)
 {
-return pls->segments[pls->cur_seq_no - pls->start_seq_no];
+int64_t n = pls->cur_seq_no - pls->start_seq_no;
+if (n >= pls->n_segments)
+return NULL;
+return pls->segments[n];
 }
 
 static struct segment *next_segment(struct playlist *pls)
@@ -1023,10 +1035,11 @@ static int read_from_url(struct playlist *pls, struct 
segment *seg,
 
 /* Parse the raw ID3 data and pass contents to caller */
 static void parse_id3(AVFormatContext *s, AVIOContext *pb,
-  AVDictionary **metadata, int64_t *dts,
+  AVDictionary **metadata, int64_t *dts, HLSAudioSetupInfo 
*audio_setup_info,
   ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta **extra_meta)
 {
 static const char id3_priv_owner_ts[] = 
"com.apple.streaming.transportStreamTimestamp";
+static const char id3_priv_owner_audio_setup[] = 
"com.apple.streaming.audioDescription";
 ID3v2ExtraMeta *meta;
 
 ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
@@ -1041,6 +1054,8 @@ static void parse_id3(AVFormatContext *s, AVIOContext *pb,
 *dts = ts;
 else
 av_log(s, AV_LOG_ERROR, "Invalid HLS ID3 audio timestamp 
%"PRId64"\n", ts);
+} else if (priv->datasize >= 8 && !strcmp(priv->owner, 
id3_priv_owner_audio_setup)) {
+ff_hls_read_audio_setup_info(audio_setup_info, priv->data, 
priv->datasize);
 }
 } else if (!strcmp(meta->tag, "APIC") && apic)
 *apic = &meta->data.apic;
@@ -1084,7 +1099,7 @@ static void handle_id3(AVIOContext *pb, struct playlist 
*pls)
 ID3v2ExtraMeta *extra_meta = NULL;
 int64_t timestamp = AV_NOPTS_VALUE;
 
-parse_id3(pls->ctx, pb, &metadata, ×tamp, &apic, &extra_meta);
+parse_id3(pls->ctx, pb, &metadata, ×tamp, &pls->audio_setup_info, 
&apic, &extra_meta);
 
 if (timestamp != AV_NOPTS_VALUE) {
 pls->id3_mpegts_timestamp = timestamp;
@@ -1238,10 +1253,7 @@ static int open_input(HLSContext *c, struct playlist 
*pls, struct segment *seg,
 av_log(pls->parent, AV_LOG_VERBOSE, "HLS request for url '%s', offset 
%"PRId64", playlist %d\n",
seg->url, seg->url_offset, pls->index);
 
-if (seg->key_type == KEY_NONE) {
-ret = open_url(pls->parent, in, seg->url, &c->avio_opts, opts, 
&is_http);
-} else if (seg->key_type == KE

Re: [FFmpeg-devel] [PATCH] avutil/buffer: free all pooled buffers immediately after uninitializing the pool

2021-02-24 Thread James Almer

On 2/24/2021 5:23 AM, Anton Khirnov wrote:

Quoting James Almer (2021-02-20 14:21:47)

No buffer will be fetched from the pool after it's uninitialized, so there's
no benefit from waiting until every single buffer has been returned to it
before freeing them all.
This should free some memory in certain scenarios, which can be beneficial in
low memory systems.

Based on a patch by Jonas Karlman.

Signed-off-by: James Almer 
---
  libavutil/buffer.c | 19 ++-
  1 file changed, 14 insertions(+), 5 deletions(-)


Looks ok.


Pushed, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/5] tests/api-flac-test: ensure the frame is writable before writing to it

2021-02-24 Thread James Almer

On 2/24/2021 7:03 AM, Anton Khirnov wrote:

The encoder may keep a reference to frames that were sent to it, so the
caller cannot modify them without checking first.
---
  tests/api/api-flac-test.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 3fea3258f3..7c96a4d99e 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -154,6 +154,10 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
  enc_pkt.data = NULL;
  enc_pkt.size = 0;
  
+result = av_frame_make_writable(in_frame);


This is going to make a copy of the existing frame data, only for the 
code below to completely replace it. It will also make copies (not 
references) of side data, if any.
Maybe instead unref it, set nb_samples, format and channel_layout again, 
then call av_frame_get_buffer() (Factoring the existing relevant code 
into its own function).


LGTM either way.


+if (result < 0)
+return result;
+
  generate_raw_frame((uint16_t*)(in_frame->data[0]), i, 
enc_ctx->sample_rate,
 enc_ctx->channels, enc_ctx->frame_size);
  in_frame_bytes = in_frame->nb_samples * in_frame->channels * 
sizeof(uint16_t);



___
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 2/4] avcodec/xpm: Minor speed increase for mod_strcspn() {string, reject}==0

2021-02-24 Thread Moritz Barsnick
On Mon, Feb 22, 2021 at 20:32:14 -0800, Jose Da Silva wrote:
> -for (i = 0; string && string[i]; i++) {
> +if (string == 0)

"if (!string)" is the preferred style for pointers.

But I don't see the advantage - isn't the loop interrupted immediately
anyway if string == NULL? (Same for the other loop you changed.)

Inside the loops, the additional checks for validity of "string"
seem redundant either way, though:

  while ( string && string[i] && string[i] != '\n' )

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] tests/api-band-test: simplify code

2021-02-24 Thread James Almer

On 2/24/2021 7:03 AM, Anton Khirnov wrote:

---
  tests/api/api-band-test.c | 6 ++
  1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
index 34bed1d6be..717c9441a4 100644
--- a/tests/api/api-band-test.c
+++ b/tests/api/api-band-test.c
@@ -167,10 +167,8 @@ static int video_decode(const char *input_filename)
  continue;
  }
  
-if (result < 0)

-result = avcodec_send_packet(ctx, NULL);
-else
-result = avcodec_send_packet(ctx, pkt);
+// pkt will be empty on read error/EOF
+result = avcodec_send_packet(ctx, pkt);
  
  av_packet_unref(pkt);


LGTM.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build warning

2021-02-24 Thread Anton Khirnov
Quoting Guo, Yejun (2021-02-20 08:22:11)
> Here is the warning message:
> src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
> src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be 
> truncated writing up to 255 bytes into a region of size 251 
> [-Wformat-truncation=]
>  snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
>   ^~
> src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261 
> bytes into a destination of size 256
>  snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
>  ^~~~
> ---
> This patch set fixes build warnings during make on my system
> with gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
> with config option:
> --disable-optimizations --enable-libx264 --enable-libx265 --enable-gpl 
> --enable-libvpx --enable-libmfx --extra-cflags="-Wno-deprecated-declarations"
> 
> I also tried '-Wall -Werror', there are many many issues starting from
> configure. It is a long term task, let's fix one by one when have time.
> 
>  libavdevice/v4l2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index 365bacd771..15ade26eed 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, 
> AVDeviceInfoList *device_l
>  return ret;
>  }
>  while ((entry = readdir(dir))) {
> -char device_name[256];
> +char device_name[261];

sizeof(entry->d_name) + 5
would be eaiser to read IMO

-- 
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] vp9: fix a race in exporting encoding parameters

2021-02-24 Thread James Almer

On 2/24/2021 6:33 AM, Anton Khirnov wrote:

Modifying shared state after ff_thread_finish_setup() is not allowed, so
set the encoding parameters directly on the output frame.


Does this also ensure the side data will be present in 
show_existing_frame frames? This means the "ret == 0" case when 
returning from decode_frame_header(), where it simply outputs an already 
decoded frame again directly from s->s.refs.


See vp90-2-10-show-existing-frame* in samples/vp9-test-vectors/



Found-by: James Almer 


By Valgrind :p


---
  libavcodec/vp9.c | 18 ++
  1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 4659f94ee8..46062f8a8f 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -1499,7 +1499,8 @@ int loopfilter_proc(AVCodecContext *avctx)
  }
  #endif
  
-static int vp9_export_enc_params(VP9Context *s, VP9Frame *frame)

+static int vp9_export_enc_params(VP9Context *s, AVFrame *frame_dst,
+ const VP9Frame *frame)
  {
  AVVideoEncParams *par;
  unsigned int tile, nb_blocks = 0;
@@ -1509,7 +1510,7 @@ static int vp9_export_enc_params(VP9Context *s, VP9Frame 
*frame)
  nb_blocks += s->td[tile].nb_block_structure;
  }
  
-par = av_video_enc_params_create_side_data(frame->tf.f,

+par = av_video_enc_params_create_side_data(frame_dst,
  AV_VIDEO_ENC_PARAMS_VP9, nb_blocks);
  if (!par)
  return AVERROR(ENOMEM);
@@ -1759,12 +1760,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
  s->td->error_info = 0;
  return AVERROR_INVALIDDATA;
  }
-if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
-ret = vp9_export_enc_params(s, &s->s.frames[CUR_FRAME]);
-if (ret < 0)
-return ret;
-}
-
  finish:
  // ref frame setup
  for (i = 0; i < 8; i++) {
@@ -1778,6 +1773,13 @@ finish:
  if (!s->s.h.invisible) {
  if ((ret = av_frame_ref(frame, s->s.frames[CUR_FRAME].tf.f)) < 0)
  return ret;
+
+if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+ret = vp9_export_enc_params(s, frame, &s->s.frames[CUR_FRAME]);
+if (ret < 0)
+return ret;
+}
+
  *got_frame = 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] Re: [PATCH 4/8] libavformat/dashenc.c: fix build warning

2021-02-24 Thread Anton Khirnov
Quoting Guo, Yejun (2021-02-20 08:22:14)
> Part of warning message:
> src/libavformat/dashenc.c: In function ‘flush_init_segment’:
> src/libavformat/dashenc.c:608:49: warning: ‘%s’ directive output may be 
> truncated writing up to 1023 bytes into a region of size between 1 and 1024 
> [-Wformat-truncation=]
>  snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
> os->initfile);
>  ^~
> src/libavformat/dashenc.c:608:9: note: ‘snprintf’ output between 1 and 2047 
> bytes into a destination of size 1024
>  snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
> os->initfile);
>  
> ^~
> ---
>  libavformat/dashenc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 

All these numbers are pretty arbitrary. Might as well make them
dynamically allocated, like AVFormatContext.url is.

-- 
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".

[FFmpeg-devel] [PATCH 1/2] avfilter/transform: Stop exporting internal functions

2021-02-24 Thread Andreas Rheinhardt
avfilter_transform, avfilter_(add|sub|mult)_matrix are not part of the
public API (transform.h is not a public header), yet they are currently
exported because of their name. This commit changes this:
avfilter_transform is renamed to ff_affine_transform; the other
functions are just removed as they have never been used at all.

Found-by: Anton Khirnov 
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/transform.c  | 23 +--
 libavfilter/transform.h  | 29 +
 libavfilter/vf_deshake.c |  5 +++--
 3 files changed, 5 insertions(+), 52 deletions(-)

diff --git a/libavfilter/transform.c b/libavfilter/transform.c
index f4f9e0a47d..1f91436f73 100644
--- a/libavfilter/transform.c
+++ b/libavfilter/transform.c
@@ -122,28 +122,7 @@ void ff_get_matrix(
 matrix[8] = 1;
 }
 
-void avfilter_add_matrix(const float *m1, const float *m2, float *result)
-{
-int i;
-for (i = 0; i < 9; i++)
-result[i] = m1[i] + m2[i];
-}
-
-void avfilter_sub_matrix(const float *m1, const float *m2, float *result)
-{
-int i;
-for (i = 0; i < 9; i++)
-result[i] = m1[i] - m2[i];
-}
-
-void avfilter_mul_matrix(const float *m1, float scalar, float *result)
-{
-int i;
-for (i = 0; i < 9; i++)
-result[i] = m1[i] * scalar;
-}
-
-int avfilter_transform(const uint8_t *src, uint8_t *dst,
+int ff_affine_transform(const uint8_t *src, uint8_t *dst,
 int src_stride, int dst_stride,
 int width, int height, const float *matrix,
 enum InterpolateMethod interpolate,
diff --git a/libavfilter/transform.h b/libavfilter/transform.h
index 9b0c19ceca..0344f9c228 100644
--- a/libavfilter/transform.h
+++ b/libavfilter/transform.h
@@ -83,33 +83,6 @@ void ff_get_matrix(
 float *matrix
 );
 
-/**
- * Add two matrices together. result = m1 + m2.
- *
- * @param m1 9-item transformation matrix
- * @param m2 9-item transformation matrix
- * @param result 9-item transformation matrix
- */
-void avfilter_add_matrix(const float *m1, const float *m2, float *result);
-
-/**
- * Subtract one matrix from another. result = m1 - m2.
- *
- * @param m1 9-item transformation matrix
- * @param m2 9-item transformation matrix
- * @param result 9-item transformation matrix
- */
-void avfilter_sub_matrix(const float *m1, const float *m2, float *result);
-
-/**
- * Multiply a matrix by a scalar value. result = m1 * scalar.
- *
- * @param m1 9-item transformation matrix
- * @param scalar a number
- * @param result 9-item transformation matrix
- */
-void avfilter_mul_matrix(const float *m1, float scalar, float *result);
-
 /**
  * Do an affine transformation with the given interpolation method. This
  * multiplies each vector [x,y,1] by the matrix and then interpolates to
@@ -126,7 +99,7 @@ void avfilter_mul_matrix(const float *m1, float scalar, 
float *result);
  * @param filledge fill method
  * @return negative on error
  */
-int avfilter_transform(const uint8_t *src, uint8_t *dst,
+int ff_affine_transform(const uint8_t *src, uint8_t *dst,
 int src_stride, int dst_stride,
 int width, int height, const float *matrix,
 enum InterpolateMethod interpolate,
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index 28a541b94a..8771399351 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -330,8 +330,9 @@ static int deshake_transform_c(AVFilterContext *ctx,
 
 for (i = 0; i < 3; i++) {
 // Transform the luma and chroma planes
-ret = avfilter_transform(in->data[i], out->data[i], in->linesize[i], 
out->linesize[i],
- plane_w[i], plane_h[i], matrixs[i], 
interpolate, fill);
+ret = ff_affine_transform(in->data[i], out->data[i], in->linesize[i],
+  out->linesize[i], plane_w[i], plane_h[i],
+  matrixs[i], interpolate, fill);
 if (ret < 0)
 return ret;
 }
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avfilter/Makefile: Don't compile transform.c unconditionally

2021-02-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 359ea7f903..f63b395fbd 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -19,7 +19,6 @@ OBJS = allfilters.o   
  \
framequeue.o \
graphdump.o  \
graphparser.o\
-   transform.o  \
video.o  \
 
 OBJS-$(HAVE_THREADS) += pthread.o
@@ -237,8 +236,8 @@ OBJS-$(CONFIG_DEJUDDER_FILTER)   += 
vf_dejudder.o
 OBJS-$(CONFIG_DELOGO_FILTER) += vf_delogo.o
 OBJS-$(CONFIG_DENOISE_VAAPI_FILTER)  += vf_misc_vaapi.o vaapi_vpp.o
 OBJS-$(CONFIG_DESHAKE_OPENCL_FILTER)+= vf_deshake_opencl.o opencl.o \
-opencl/deshake.o
-OBJS-$(CONFIG_DESHAKE_FILTER)+= vf_deshake.o
+opencl/deshake.o transform.o
+OBJS-$(CONFIG_DESHAKE_FILTER)+= vf_deshake.o transform.o
 OBJS-$(CONFIG_DESPILL_FILTER)+= vf_despill.o
 OBJS-$(CONFIG_DETELECINE_FILTER) += vf_detelecine.o
 OBJS-$(CONFIG_DILATION_FILTER)   += vf_neighbor.o
-- 
2.27.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] Re: [PATCH] avformat/vividas: Use signed n in read_sb_block()

2021-02-24 Thread Anton Khirnov
Quoting Michael Niedermayer (2021-02-15 21:31:23)
> Fixes: OOM
> Fixes: 
> 27780/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5097985075314688
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/vividas.c b/libavformat/vividas.c
> index d745770dc4..b172a48b29 100644
> --- a/libavformat/vividas.c
> +++ b/libavformat/vividas.c
> @@ -235,7 +235,7 @@ static uint8_t *read_sb_block(AVIOContext *src, unsigned 
> *size,
>  uint8_t *buf;
>  uint8_t ibuf[8], sbuf[8];
>  uint32_t k2;
> -unsigned n;
> +int n;
>  

Why would that be better, when it's assigned a uint32_t?

-- 
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 0/4] avcodec Loongson-2 MMI fixes

2021-02-24 Thread Jiaxun Yang


On Tue, Feb 23, 2021, at 2:47 PM, 殷时友 wrote:
> 
> > 2021年2月19日 下午1:28,Jiaxun Yang  写道:
> > 
> > Get MMI optimizations build for Loongson-2 again.
> > Tested on Loongson-2 and Loongson-3A.
> > 
> > Jiaxun Yang (4):
> >  avutil/mips: Use MMI_{L,S}QC1 macro in {SAVE,RECOVER}_REG
> >  avutil/mips: Extract load store with shift C1 pair marco
> >  avcodec/mips: Use MMI marcos to replace Loongson3 instructions
> >  avutil/mips: Use $at as MMI macro temporary register
> > 
> > libavcodec/mips/h264chroma_mmi.c  |  26 +++-
> > libavcodec/mips/h264dsp_mmi.c |   8 +-
> > libavcodec/mips/hevcdsp_mmi.c | 251 --
> > libavcodec/mips/hpeldsp_mmi.c |   1 +
> > libavcodec/mips/simple_idct_mmi.c |  49 +++---
> > libavcodec/mips/vp3dsp_idct_mmi.c |  11 +-
> > libavcodec/mips/vp8dsp_mmi.c  | 100 +---
> > libavcodec/mips/vp9_mc_mmi.c  | 128 ++-
> > libavutil/mips/mmiutils.h | 174 +
> > 9 files changed, 350 insertions(+), 398 deletions(-)
> > 
> > -- 
> > 2.30.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”.
> 
> It's better to merge first three patches into one, otherwise the first 
> two patches will cause build error.

Thanks for your comments. I was thinking about make my changes clear but 
ability of bisect is important as well.

Will send v2 later.

- Jiaxun

> 
> 
>

-- 
- Jiaxun
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/transform: Stop exporting internal functions

2021-02-24 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/transform: Stop exporting internal functions

2021-02-24 Thread James Almer

On 2/24/2021 11:22 AM, Andreas Rheinhardt wrote:

avfilter_transform, avfilter_(add|sub|mult)_matrix are not part of the
public API (transform.h is not a public header), yet they are currently
exported because of their name. This commit changes this:
avfilter_transform is renamed to ff_affine_transform; the other
functions are just removed as they have never been used at all.


The symbols are exported and have been in four releases so far for this 
soname. If we plan on making a 4.4 release before the bump, it may be a 
good idea if we keep the symbols around for the sake of not affecting 
the ABI, so I'm inclined towards just wrapping them in a 
LIBAVFILTER_VERSION_MAJOR < 8 check like we do when we remove avpriv ones.




Found-by: Anton Khirnov 
Signed-off-by: Andreas Rheinhardt 
---
  libavfilter/transform.c  | 23 +--
  libavfilter/transform.h  | 29 +
  libavfilter/vf_deshake.c |  5 +++--
  3 files changed, 5 insertions(+), 52 deletions(-)

diff --git a/libavfilter/transform.c b/libavfilter/transform.c
index f4f9e0a47d..1f91436f73 100644
--- a/libavfilter/transform.c
+++ b/libavfilter/transform.c
@@ -122,28 +122,7 @@ void ff_get_matrix(
  matrix[8] = 1;
  }
  
-void avfilter_add_matrix(const float *m1, const float *m2, float *result)

-{
-int i;
-for (i = 0; i < 9; i++)
-result[i] = m1[i] + m2[i];
-}
-
-void avfilter_sub_matrix(const float *m1, const float *m2, float *result)
-{
-int i;
-for (i = 0; i < 9; i++)
-result[i] = m1[i] - m2[i];
-}
-
-void avfilter_mul_matrix(const float *m1, float scalar, float *result)
-{
-int i;
-for (i = 0; i < 9; i++)
-result[i] = m1[i] * scalar;
-}
-
-int avfilter_transform(const uint8_t *src, uint8_t *dst,
+int ff_affine_transform(const uint8_t *src, uint8_t *dst,
  int src_stride, int dst_stride,
  int width, int height, const float *matrix,
  enum InterpolateMethod interpolate,
diff --git a/libavfilter/transform.h b/libavfilter/transform.h
index 9b0c19ceca..0344f9c228 100644
--- a/libavfilter/transform.h
+++ b/libavfilter/transform.h
@@ -83,33 +83,6 @@ void ff_get_matrix(
  float *matrix
  );
  
-/**

- * Add two matrices together. result = m1 + m2.
- *
- * @param m1 9-item transformation matrix
- * @param m2 9-item transformation matrix
- * @param result 9-item transformation matrix
- */
-void avfilter_add_matrix(const float *m1, const float *m2, float *result);
-
-/**
- * Subtract one matrix from another. result = m1 - m2.
- *
- * @param m1 9-item transformation matrix
- * @param m2 9-item transformation matrix
- * @param result 9-item transformation matrix
- */
-void avfilter_sub_matrix(const float *m1, const float *m2, float *result);
-
-/**
- * Multiply a matrix by a scalar value. result = m1 * scalar.
- *
- * @param m1 9-item transformation matrix
- * @param scalar a number
- * @param result 9-item transformation matrix
- */
-void avfilter_mul_matrix(const float *m1, float scalar, float *result);
-
  /**
   * Do an affine transformation with the given interpolation method. This
   * multiplies each vector [x,y,1] by the matrix and then interpolates to
@@ -126,7 +99,7 @@ void avfilter_mul_matrix(const float *m1, float scalar, 
float *result);
   * @param filledge fill method
   * @return negative on error
   */
-int avfilter_transform(const uint8_t *src, uint8_t *dst,
+int ff_affine_transform(const uint8_t *src, uint8_t *dst,
  int src_stride, int dst_stride,
  int width, int height, const float *matrix,
  enum InterpolateMethod interpolate,
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index 28a541b94a..8771399351 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -330,8 +330,9 @@ static int deshake_transform_c(AVFilterContext *ctx,
  
  for (i = 0; i < 3; i++) {

  // Transform the luma and chroma planes
-ret = avfilter_transform(in->data[i], out->data[i], in->linesize[i], 
out->linesize[i],
- plane_w[i], plane_h[i], matrixs[i], 
interpolate, fill);
+ret = ff_affine_transform(in->data[i], out->data[i], in->linesize[i],
+  out->linesize[i], plane_w[i], plane_h[i],
+  matrixs[i], interpolate, fill);
  if (ret < 0)
  return ret;
  }



___
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] lavc/lscrdec: use ff_reget_buffer()

2021-02-24 Thread James Almer

On 2/24/2021 5:40 AM, Anton Khirnov wrote:

It is simpler and more efficient.

Suggested-by: James Almer 
---
  libavcodec/lscrdec.c | 17 ++---
  1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/libavcodec/lscrdec.c b/libavcodec/lscrdec.c
index d5388c22ac..e706dda9da 100644
--- a/libavcodec/lscrdec.c
+++ b/libavcodec/lscrdec.c
@@ -105,7 +105,7 @@ static int decode_frame_lscr(AVCodecContext *avctx,
  {
  LSCRContext *const s = avctx->priv_data;
  GetByteContext *gb = &s->gb;
-AVFrame *frame = data;
+AVFrame *frame = s->last_picture;
  int ret, nb_blocks, offset = 0;
  
  if (avpkt->size < 2)

@@ -115,18 +115,14 @@ static int decode_frame_lscr(AVCodecContext *avctx,
  
  bytestream2_init(gb, avpkt->data, avpkt->size);
  
-if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)

-return ret;
-
  nb_blocks = bytestream2_get_le16(gb);
  if (bytestream2_get_bytes_left(gb) < 2 + nb_blocks * (12 + 8))
  return AVERROR_INVALIDDATA;
  
-if (s->last_picture->data[0]) {

-ret = av_frame_copy(frame, s->last_picture);
-if (ret < 0)
-return ret;
-}
+ret = ff_reget_buffer(avctx, frame,
+  nb_blocks ? 0 : FF_REGET_BUFFER_FLAG_READONLY);
+if (ret < 0)
+return ret;
  
  for (int b = 0; b < nb_blocks; b++) {

  int x, y, x2, y2, w, h, left;
@@ -216,8 +212,7 @@ static int decode_frame_lscr(AVCodecContext *avctx,
  
  frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
  
-av_frame_unref(s->last_picture);

-if ((ret = av_frame_ref(s->last_picture, frame)) < 0)
+if ((ret = av_frame_ref(data, frame)) < 0)
  return ret;
  
  *got_frame = 1;


LGTM.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build warning

2021-02-24 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Anton
> Khirnov
> Sent: 2021年2月24日 22:05
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build warning
> 
> Quoting Guo, Yejun (2021-02-20 08:22:11)
> > Here is the warning message:
> > src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
> > src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be
> truncated writing up to 255 bytes into a region of size 251
> [-Wformat-truncation=]
> >  snprintf(device_name, sizeof(device_name), "/dev/%s",
> entry->d_name);
> >   ^~
> > src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261
> bytes into a destination of size 256
> >  snprintf(device_name, sizeof(device_name), "/dev/%s",
> entry->d_name);
> >
> >
> ^~~
> ~
> > ---
> > This patch set fixes build warnings during make on my system with gcc
> > version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) with config option:
> > --disable-optimizations --enable-libx264 --enable-libx265 --enable-gpl
> --enable-libvpx --enable-libmfx --extra-cflags="-Wno-deprecated-declarations"
> >
> > I also tried '-Wall -Werror', there are many many issues starting from
> > configure. It is a long term task, let's fix one by one when have time.
> >
> >  libavdevice/v4l2.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index
> > 365bacd771..15ade26eed 100644
> > --- a/libavdevice/v4l2.c
> > +++ b/libavdevice/v4l2.c
> > @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext
> *ctx, AVDeviceInfoList *device_l
> >  return ret;
> >  }
> >  while ((entry = readdir(dir))) {
> > -char device_name[256];
> > +char device_name[261];
> 
> sizeof(entry->d_name) + 5
> would be eaiser to read IMO

yes, will update the patches, and send all with V2 except patch 7 which has 
been fixed with 1c9e53d7
___
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] Proposal of two projects for GSoC

2021-02-24 Thread Artem Galin
Hello,



Please find the proposal for the following two projects for GSoC this year.

The FATE project had been proposed earlier already but I don't know why it
didn't happen.

I previously got the feedback from Thilo Borgmann and would be happy to get
feedback from the community as well.



"



FATE tests for HW acceleration



Description: FFmpeg's FATE regression test system do not include validation
of hardware acceleration. This project is about to include these
hardware-specific regression tests to the FATE system. Since this project
requires access to corresponding hardware, it is not expected to cover the
whole range of hardware accelerators there are but to initialize some
useful tests for available hardware, most likely to include CPU
acceleration on Intel or AMD at least. Access to other hardware can also be
provided during the project, depending on the students requirements.



Expected results: Implement tests for the different hardware decoding,
encoding and transcoding capabilities there are.



Prerequisites: Good C and Makefile coding skills, basic familiarity with
Git.



Qualification Task: TBD



Mentor: Artem G (artem.galin [at] intel [dot] com)



Backup Mentor: TBD



"





Title: oneAPI Video Processing Library (oneVPL) for CPU & GPU hardware
accelleration (https://www.oneapi.com/)



Description: Add support for oneVPL



The oneAPI project is developing a common cross-platform API for video
processing, including CPU and GPU hardware acceleration.



At least Intel's MediaSDK (https://github.com/Intel-Media-SDK/MediaSDK <
https://github.com/Intel-Media-SDK/MediaSDK>), providing the currently used
QSV API used for HW acceleration on Intel, will transition to implement the
oneAPI API, called oneVPL (https://github.com/oneapi-src/oneVPL).



Therefore, this project aims to get FFmpeg ready for this new API to ensure
future availability of not only Intel's HW acceleration after the
transition to oneVPL but also for possible other implementations of the
oneAPI from other vendors.





Expected results: Implement a oneVPL library wrapper into FFmpeg.

Validate that media pipelines work with no regressions by supported feature
set and performance.





Prerequisites: Good C and Makefile coding skills, basic familiarity with
Git.



Qualification Task: TBD



Mentor: Artem G (artem.galin [at] intel [dot] com)



Backup Mentor: TBD





"



Thanks,

Artem.
___
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 3/3] avformat: add Digital Pictures SGA game demuxer

2021-02-24 Thread Anton Khirnov
Quoting Paul B Mahol (2021-02-23 18:25:09)
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/sga.c| 388 +++
>  3 files changed, 390 insertions(+)
>  create mode 100644 libavformat/sga.c

How about a test?

-- 
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 3/3] avformat: add Digital Pictures SGA game demuxer

2021-02-24 Thread Paul B Mahol
On Wed, Feb 24, 2021 at 4:47 PM Anton Khirnov  wrote:

> Quoting Paul B Mahol (2021-02-23 18:25:09)
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libavformat/Makefile |   1 +
> >  libavformat/allformats.c |   1 +
> >  libavformat/sga.c| 388 +++
> >  3 files changed, 390 insertions(+)
> >  create mode 100644 libavformat/sga.c
>
> How about a test?
>

Later.


>
> --
> 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".
___
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/x86: add cfhdenc SIMD

2021-02-24 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/cfhdencdsp.c  |   3 +
 libavcodec/x86/Makefile  |   2 +
 libavcodec/x86/cfhdencdsp.asm| 429 +++
 libavcodec/x86/cfhdencdsp_init.c |  48 
 4 files changed, 482 insertions(+)
 create mode 100644 libavcodec/x86/cfhdencdsp.asm
 create mode 100644 libavcodec/x86/cfhdencdsp_init.c

diff --git a/libavcodec/cfhdencdsp.c b/libavcodec/cfhdencdsp.c
index 0becb76d1d..b979e9e09a 100644
--- a/libavcodec/cfhdencdsp.c
+++ b/libavcodec/cfhdencdsp.c
@@ -73,4 +73,7 @@ av_cold void ff_cfhdencdsp_init(CFHDEncDSPContext *c)
 {
 c->horiz_filter = horiz_filter;
 c->vert_filter = vert_filter;
+
+if (ARCH_X86)
+ff_cfhdencdsp_init_x86(c);
 }
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 884dc0c759..6361161180 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -51,6 +51,7 @@ OBJS-$(CONFIG_ALAC_DECODER)+= x86/alacdsp_init.o
 OBJS-$(CONFIG_APNG_DECODER)+= x86/pngdsp_init.o
 OBJS-$(CONFIG_CAVS_DECODER)+= x86/cavsdsp.o
 OBJS-$(CONFIG_CFHD_DECODER)+= x86/cfhddsp_init.o
+OBJS-$(CONFIG_CFHD_ENCODER)+= x86/cfhdencdsp_init.o
 OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o 
x86/synth_filter_init.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += x86/dnxhdenc_init.o
 OBJS-$(CONFIG_EXR_DECODER) += x86/exrdsp_init.o
@@ -154,6 +155,7 @@ X86ASM-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp.o
 X86ASM-OBJS-$(CONFIG_ALAC_DECODER) += x86/alacdsp.o
 X86ASM-OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp.o
 X86ASM-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsidct.o
+X86ASM-OBJS-$(CONFIG_CFHD_ENCODER) += x86/cfhdencdsp.o
 X86ASM-OBJS-$(CONFIG_CFHD_DECODER) += x86/cfhddsp.o
 X86ASM-OBJS-$(CONFIG_DCA_DECODER)  += x86/dcadsp.o x86/synth_filter.o
 X86ASM-OBJS-$(CONFIG_DIRAC_DECODER)+= x86/diracdsp.o\
diff --git a/libavcodec/x86/cfhdencdsp.asm b/libavcodec/x86/cfhdencdsp.asm
new file mode 100644
index 00..1753b7829a
--- /dev/null
+++ b/libavcodec/x86/cfhdencdsp.asm
@@ -0,0 +1,429 @@
+;**
+;* x86-optimized functions for the CFHD encoder
+;* Copyright (c) 2021 Paul B Mahol
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;**
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+pw_p1_n1:  dw  1, -1, 1, -1, 1, -1, 1, -1
+pw_n1_p1:  dw  -1, 1, -1, 1, -1, 1, -1, 1
+pw_p5_n11: dw  5, -11, 5, -11, 5, -11, 5, -11
+pw_n5_p11: dw -5, 11, -5, 11, -5, 11, -5, 11
+pw_p11_n5: dw 11, -5, 11, -5, 11, -5, 11, -5
+pw_n11_p5: dw -11, 5, -11, 5, -11, 5, -11, 5
+pd_4:  times 4 dd  4
+pw_p4: times 8 dw  4
+pw_n4: times 8 dw -4
+pw_p1: times 8 dw  1
+pw_n1: times 8 dw -1
+
+SECTION .text
+
+%if ARCH_X86_64
+INIT_XMM sse2
+cglobal cfhdenc_horiz_filter, 8, 10, 11, input, low, high, istride, lwidth, 
hwidth, width, y, x, temp
+shl  istrided, 1
+shl   lwidthd, 1
+shl   hwidthd, 1
+mova   m7, [pd_4]
+mova   m8, [pw_p1]
+mova   m9, [pw_n1]
+mova   m10,[pw_p1_n1]
+negyq
+.looph:
+movsx  xq, word [inputq]
+
+movsx   tempq, word [inputq + 2]
+add tempq, xq
+
+movd  xm0, tempd
+packssdw   m0, m0
+pextrw  tempd, xm0, 0
+mov   word [lowq], tempw
+
+movsx  xq, word [inputq]
+imul   xq, 5
+movsx   tempq, word [inputq + 2]
+imultempq, -11
+add tempq, xq
+
+movsx  xq, word [inputq + 4]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 6]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 8]
+imul   xq, -1
+add tempq, xq
+
+movsx  xq, word [inputq + 10]
+imul   xq, -1
+add tempq, xq
+
+add tempq, 4
+sar tempq, 3
+
+movd  xm0, tempd
+packssdw   m0, m0
+pextrw  tempd, xm0, 0
+mov  word [highq], tempw
+
+movxq, 2
+
+.loopw:
+movu   m0, [inputq + x

Re: [FFmpeg-devel] [FFmpeg-web][PATCH] web/download: add signing key and verification instructions

2021-02-24 Thread Thilo Borgmann
Am 24.02.21 um 05:06 schrieb Zane van Iperen:
> As per discussion at [1]. Patches attached.
> 
> Patch 1/3 adds /node_modules/ to .gitignore
> 
> Patch 2/3 adds the actual key and verification instructions
> 
> Patch 3/3 adds a prominent download link for the public key.
> This might be bit obnoxious, but it was suggested in the original discussion.
> 
> [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/276752.html

As in [1] above I like that idea. However, I can't really comment on the 
technical side of keys and signatures. So proper someones opinion with actual 
knowledge would be appreciated.

Thanks!
-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".

Re: [FFmpeg-devel] Proposal of two projects for GSoC

2021-02-24 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Artem Galin
> Sent: Wednesday, February 24, 2021 4:40 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] Proposal of two projects for GSoC
> 


> 
> Please find the proposal for the following two projects for GSoC this year.
> 

> 
> Title: oneAPI Video Processing Library (oneVPL) for CPU & GPU hardware
> accelleration (https://www.oneapi.com/)
> 
> Description: Add support for oneVPL
> 

Hi Artem,

I hope your doing fine! Your v7 patch for D3D11 QSV is now mostly identical
to my original code (except defaulting to D3D11), and I'm pretty glad about
that outcome. Probably meanwhile you came to understand why I didn't
want to submit the code myself, but I hadn't expected that even Intel is
being ignored here for so long :-(

That being said, I have two questions regarding oneVPL:

1. From all the docs I've read, it was always about limitations of oneVPL
   In relation to MediaSDK. Is there a single thing which oneVPL can do
   that can't  be done with MediaSDK?

2. Will MediaSDK be discontinued, renamed or continued to coexist with
   oneVPL?

Thanks and kind regards,
softworkz

 
___
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 v7 2/8] libavutil/hwcontext_qsv: supporting d3d11va device type

2021-02-24 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Artem Galin
> Sent: Tuesday, November 3, 2020 7:46 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Artem Galin 
> Subject: [FFmpeg-devel] [PATCH v7 2/8] libavutil/hwcontext_qsv: supporting
> d3d11va device type
> 
> This enables usage of non-powered/headless GPU, better HDR support.
> Pool of resources is allocated as one texture with array of slices.
> 
> Signed-off-by: Artem Galin 
> ---
>  libavutil/hwcontext_qsv.c | 323 +++
> ---
>  1 file changed, 262 insertions(+), 61 deletions(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 35a944f8f8..1f5a3d1c57 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -27,9 +27,13 @@


Hi Artem,

A while ago I had merged and aligned your v7 patch in order to become equal
and to verify the patch. There has been one scenario that didn't work anymore,
but I just can remember what it was exactly. That means unfortunately that I
can't proof this by providing an exact repro case.

But it must have been one of the following:

- hwdownload from a QSV filter
- hwupload to a QSV filter
- hwupload to a QSV encoder
- hybrid pipeline with D3D11VA decoder
  - deriving to QSV encoder ... or
  - deriving to QSV filter

At least I know the reason: you had simplified my qsv_get_d3d11va_bind_flags
function, and some tiny bit of the logic got lost by doing so.

I apologize for being a bit vague, I should have made some notes when I had
seen it. I hope it is still useful in some way.

Kind regards,
softworkz

___
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 v7 8/8] libavfilter/vf_deinterlace_qsv: enabling d3d11va support, added mfxhdlpair

2021-02-24 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Artem Galin
> Sent: Tuesday, November 3, 2020 7:46 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Artem Galin 
> Subject: [FFmpeg-devel] [PATCH v7 8/8] libavfilter/vf_deinterlace_qsv:
> enabling d3d11va support, added mfxhdlpair
> 
> Adding DX11 relevant device type checks and adjusting callback with proper
> MediaSDK pair type support.
> 

Hi Artem,

I have a few more notes regarding the patch:

The switch to using mfxhdlpair will cause a regression in case of VAAPI/OpenCL
Interop. In hwcontext_opencl.cs, function opencl_map_from_qsv, you need to
cast the MemId to mfxHDLPair for getting the surface id.

OpenCL interop on Windows is a whole different story, but it's not a small thing
like the above, so you better handle that at a later time. It's not a 
regression 
anyway because this functionality doesn't exist yet (for D3D11).

At the same time, that's another reason for NOT changing the default to D3D11
because somebody using QSV<=>OpenCL interop would see his commands 
failing when you change the default to D3D11.

I don't know what others here are thinking (because nobody says anything),
but IMO, a patch that doesn't switch the default impl would have less
impact and probably better chances to get merged.

Kind regards,
softworkz



___
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] filters/metadata: add CSV output support

2021-02-24 Thread Werner Robitza
This adds a new option to the metadata filter that allows outputting CSV data.
The separator can be set via another option.
Special characters are handled via escaping.

Signed-off-by: Werner Robitza 
---
 doc/filters.texi |  14 
 libavfilter/f_metadata.c | 155 ---
 2 files changed, 158 insertions(+), 11 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 426cb158da..0b56d73565 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25134,6 +25134,20 @@ with AV_LOG_INFO loglevel.
 @item direct
 Reduces buffering in print mode when output is written to a URL set using 
@var{file}.
 
+@item format
+Set the output format for the print mode.
+
+@table @samp
+@item default
+Default output format
+
+@item csv
+Comma-separated output
+@end table
+
+@item csv_sep
+Set the CSV separator (only valid for CSV format). Default is @code{,}. Must be
+one character and cannot be a period (@code{.}).
 @end table
 
 @subsection Examples
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index 598257b15b..45f5eeddcd 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -58,6 +58,11 @@ enum MetadataFunction {
 METADATAF_NB
 };
 
+enum MetadataFormat {
+METADATA_FORMAT_DEFAULT,
+METADATA_FORMAT_CSV
+};
+
 static const char *const var_names[] = {
 "VALUE1",
 "VALUE2",
@@ -85,6 +90,9 @@ typedef struct MetadataContext {
 AVIOContext* avio_context;
 char *file_str;
 
+int format;
+char *csv_sep;
+
 int (*compare)(struct MetadataContext *s,
const char *value1, const char *value2);
 void (*print)(AVFilterContext *ctx, const char *msg, ...) 
av_printf_format(2, 3);
@@ -114,6 +122,10 @@ static const AVOption filt_name##_options[] = { \
 { "expr", "set expression for expr function", OFFSET(expr_str), 
AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
 { "file", "set file where to print metadata information", 
OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \
 { "direct", "reduce buffering when printing to user-set file or pipe", 
OFFSET(direct), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, \
+{ "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, {.i64 = 
0 }, 0, METADATAF_NB-1, FLAGS, "format" }, \
+{   "default", "default format",  0, AV_OPT_TYPE_CONST, {.i64 = 
METADATA_FORMAT_DEFAULT }, 0, 0, FLAGS, "format" }, \
+{   "csv", "comma-separated", 0, AV_OPT_TYPE_CONST, {.i64 = 
METADATA_FORMAT_CSV }, 0, 0, FLAGS, "format" }, \
+{ "csv_sep", "set CSV separator (only valid for CSV format)", 
OFFSET(csv_sep), AV_OPT_TYPE_STRING, {.str=","},  0, 0, FLAGS }, \
 { NULL } \
 }
 
@@ -202,6 +214,58 @@ static void print_file(AVFilterContext *ctx, const char 
*msg, ...)
 va_end(argument_list);
 }
 
+static void print_csv_escaped(AVFilterContext *ctx, const char *src)
+{
+MetadataContext *s = ctx->priv;
+
+char meta_chars[] = {s->csv_sep[0], '"', '\n', '\r', '\0'};
+int needs_quoting = !!src[strcspn(src, meta_chars)];
+
+// allocate space for two extra quotes and possibly every char escaped
+char buf[strlen(src) * 2 + 2];
+
+int pos = 0;
+
+if (needs_quoting)
+buf[pos++] = '"';
+
+for (int i = 0; i < strlen(src); i++) {
+if (src[i] == '"')
+buf[pos++] = '\"';
+buf[pos++] = src[i];
+}
+
+if (needs_quoting)
+buf[pos++] = '"';
+
+buf[pos] = '\0';
+
+s->print(ctx, "%s", buf);
+}
+
+static void csv_escape(const char *src, char **dst, const char csv_sep)
+{
+char meta_chars[] = {csv_sep, '"', '\n', '\r', '\0'};
+int needs_quoting = !!src[strcspn(src, meta_chars)];
+
+int pos = 0;
+
+if (needs_quoting)
+*dst[pos++] = '"';
+
+for (int i = 0; i < strlen(src); i++)
+{
+if (src[i] == '"')
+*dst[pos++] = '\"';
+*dst[pos++] = src[i];
+}
+
+if (needs_quoting)
+*dst[pos++] = '"';
+
+*dst[pos] = '\0';
+}
+
 static av_cold int init(AVFilterContext *ctx)
 {
 MetadataContext *s = ctx->priv;
@@ -282,6 +346,33 @@ static av_cold int init(AVFilterContext *ctx)
 s->avio_context->direct = AVIO_FLAG_DIRECT;
 }
 
+if (s->format == METADATA_FORMAT_CSV) {
+if (strlen(s->csv_sep) == 0) {
+av_log(ctx, AV_LOG_ERROR,
+   "No CSV separator supplied\n");
+return AVERROR(EINVAL);
+}
+if (strlen(s->csv_sep) > 1) {
+av_log(ctx, AV_LOG_ERROR,
+   "CSV separator must be one character only\n");
+return AVERROR(EINVAL);
+}
+if (s->csv_sep[0] == '.') {
+av_log(ctx, AV_LOG_ERROR,
+   "CSV separator cannot be a single period ('.')\n");
+return AVERROR(EINVAL);
+}
+s->print(
+ctx,
+"%s%s%s%s%s%s%s%s%s\n",
+"frame", s->csv_sep,
+"pts", s->csv_sep,

Re: [FFmpeg-devel] [PATCH] filters/metadata: add CSV output support

2021-02-24 Thread Paul B Mahol
Why duplicating code that would give same output as ffprobe?

On Wed, Feb 24, 2021 at 9:01 PM Werner Robitza 
wrote:

> This adds a new option to the metadata filter that allows outputting CSV
> data.
> The separator can be set via another option.
> Special characters are handled via escaping.
>
> Signed-off-by: Werner Robitza 
> ---
>  doc/filters.texi |  14 
>  libavfilter/f_metadata.c | 155 ---
>  2 files changed, 158 insertions(+), 11 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 426cb158da..0b56d73565 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -25134,6 +25134,20 @@ with AV_LOG_INFO loglevel.
>  @item direct
>  Reduces buffering in print mode when output is written to a URL set using
> @var{file}.
>
> +@item format
> +Set the output format for the print mode.
> +
> +@table @samp
> +@item default
> +Default output format
> +
> +@item csv
> +Comma-separated output
> +@end table
> +
> +@item csv_sep
> +Set the CSV separator (only valid for CSV format). Default is @code{,}.
> Must be
> +one character and cannot be a period (@code{.}).
>  @end table
>
>  @subsection Examples
> diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
> index 598257b15b..45f5eeddcd 100644
> --- a/libavfilter/f_metadata.c
> +++ b/libavfilter/f_metadata.c
> @@ -58,6 +58,11 @@ enum MetadataFunction {
>  METADATAF_NB
>  };
>
> +enum MetadataFormat {
> +METADATA_FORMAT_DEFAULT,
> +METADATA_FORMAT_CSV
> +};
> +
>  static const char *const var_names[] = {
>  "VALUE1",
>  "VALUE2",
> @@ -85,6 +90,9 @@ typedef struct MetadataContext {
>  AVIOContext* avio_context;
>  char *file_str;
>
> +int format;
> +char *csv_sep;
> +
>  int (*compare)(struct MetadataContext *s,
> const char *value1, const char *value2);
>  void (*print)(AVFilterContext *ctx, const char *msg, ...)
> av_printf_format(2, 3);
> @@ -114,6 +122,10 @@ static const AVOption filt_name##_options[] = { \
>  { "expr", "set expression for expr function", OFFSET(expr_str),
> AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
>  { "file", "set file where to print metadata information",
> OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \
>  { "direct", "reduce buffering when printing to user-set file or
> pipe", OFFSET(direct), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, \
> +{ "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT,
> {.i64 = 0 }, 0, METADATAF_NB-1, FLAGS, "format" }, \
> +{   "default", "default format",  0, AV_OPT_TYPE_CONST, {.i64 =
> METADATA_FORMAT_DEFAULT }, 0, 0, FLAGS, "format" }, \
> +{   "csv", "comma-separated", 0, AV_OPT_TYPE_CONST, {.i64 =
> METADATA_FORMAT_CSV }, 0, 0, FLAGS, "format" }, \
> +{ "csv_sep", "set CSV separator (only valid for CSV format)",
> OFFSET(csv_sep), AV_OPT_TYPE_STRING, {.str=","},  0, 0, FLAGS }, \
>  { NULL } \
>  }
>
> @@ -202,6 +214,58 @@ static void print_file(AVFilterContext *ctx, const
> char *msg, ...)
>  va_end(argument_list);
>  }
>
> +static void print_csv_escaped(AVFilterContext *ctx, const char *src)
> +{
> +MetadataContext *s = ctx->priv;
> +
> +char meta_chars[] = {s->csv_sep[0], '"', '\n', '\r', '\0'};
> +int needs_quoting = !!src[strcspn(src, meta_chars)];
> +
> +// allocate space for two extra quotes and possibly every char escaped
> +char buf[strlen(src) * 2 + 2];
> +
> +int pos = 0;
> +
> +if (needs_quoting)
> +buf[pos++] = '"';
> +
> +for (int i = 0; i < strlen(src); i++) {
> +if (src[i] == '"')
> +buf[pos++] = '\"';
> +buf[pos++] = src[i];
> +}
> +
> +if (needs_quoting)
> +buf[pos++] = '"';
> +
> +buf[pos] = '\0';
> +
> +s->print(ctx, "%s", buf);
> +}
> +
> +static void csv_escape(const char *src, char **dst, const char csv_sep)
> +{
> +char meta_chars[] = {csv_sep, '"', '\n', '\r', '\0'};
> +int needs_quoting = !!src[strcspn(src, meta_chars)];
> +
> +int pos = 0;
> +
> +if (needs_quoting)
> +*dst[pos++] = '"';
> +
> +for (int i = 0; i < strlen(src); i++)
> +{
> +if (src[i] == '"')
> +*dst[pos++] = '\"';
> +*dst[pos++] = src[i];
> +}
> +
> +if (needs_quoting)
> +*dst[pos++] = '"';
> +
> +*dst[pos] = '\0';
> +}
> +
>  static av_cold int init(AVFilterContext *ctx)
>  {
>  MetadataContext *s = ctx->priv;
> @@ -282,6 +346,33 @@ static av_cold int init(AVFilterContext *ctx)
>  s->avio_context->direct = AVIO_FLAG_DIRECT;
>  }
>
> +if (s->format == METADATA_FORMAT_CSV) {
> +if (strlen(s->csv_sep) == 0) {
> +av_log(ctx, AV_LOG_ERROR,
> +   "No CSV separator supplied\n");
> +return AVERROR(EINVAL);
> +}
> +if (strlen(s->csv_sep) > 1) {
> +av_log(ctx, AV_LOG_ERROR,
> +   "CSV separator must be one 

Re: [FFmpeg-devel] [PATCH] filters/metadata: add CSV output support

2021-02-24 Thread Werner Robitza
On Wed, Feb 24, 2021 at 9:11 PM Paul B Mahol  wrote:
>
> Why duplicating code that would give same output as ffprobe?

I was told to here:
http://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/275510.html

Could please show an example on how to achieve this with ffprobe?
___
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] filters/metadata: add CSV output support

2021-02-24 Thread Nicolas George
Werner Robitza (12021-02-24):
> I was told to here:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/275510.html

I never told you to duplicate code. Code duplication is almost always a
motive for rejection.

If you are tempted to duplicate code, what you need to do is to share it
between the various places that use it. Making it a proper API if
relevant.

Ideally, all the writers of ffprobe should be turned into a single
libavutil API for use in all components that need to output data.

Regards,

-- 
  Nicolas George


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] filters/metadata: add CSV output support

2021-02-24 Thread Werner Robitza
On Wed, Feb 24, 2021 at 9:51 PM Nicolas George  wrote:
> I never told you to duplicate code. Code duplication is almost always a
> motive for rejection.
>
> If you are tempted to duplicate code, what you need to do is to share it
> between the various places that use it. Making it a proper API if
> relevant.

I didn't really duplicate anything; this was mostly from scratch. The
case could be made that a function for escaping CSV could be shared.
There are at least two such functions already in the code base.

> Ideally, all the writers of ffprobe should be turned into a single
> libavutil API for use in all components that need to output data.

That'd make sense.
___
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] Feature request

2021-02-24 Thread Jimmy Jaffe
Hi people. Now it is very common videos recorded with bad rotations. With 
ffmpeg it is possible to rotate without re-encoding the video using the 
'rotate' instruction. But if the video has more than one rotation it is not 
possible. Will it be possible to add rotation instructions with time? For 
example, if a video starts vertically and after a minute it needs to be rotated 
horizontally, an instruction such as 'rotate = 90 60sec', which would mean that 
from second 60 rotate 90 degrees. This is possible?, I repeat without 
re-encoding.
___
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] Feature request

2021-02-24 Thread Paul B Mahol
Not possible.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/transform: Stop exporting internal functions

2021-02-24 Thread Andreas Rheinhardt
James Almer:
> On 2/24/2021 11:22 AM, Andreas Rheinhardt wrote:
>> avfilter_transform, avfilter_(add|sub|mult)_matrix are not part of the
>> public API (transform.h is not a public header), yet they are currently
>> exported because of their name. This commit changes this:
>> avfilter_transform is renamed to ff_affine_transform; the other
>> functions are just removed as they have never been used at all.
> 
> The symbols are exported and have been in four releases so far for this
> soname. If we plan on making a 4.4 release before the bump, it may be a
> good idea if we keep the symbols around for the sake of not affecting
> the ABI, so I'm inclined towards just wrapping them in a
> LIBAVFILTER_VERSION_MAJOR < 8 check like we do when we remove avpriv ones.
> 

And why? There was never a legitimate outside user of these functions.
And removing avfilter_all_channel_layouts in
d5e5c6862bbc834d5a036a3fa053a7569d84f928 (which also didn't have a
legitimate outside user) didn't seem to break anything either.
Btw: 88d80cb97528d52dac3178cf5393d6095eca6200 broke ABI for x64, because
older versions of libavformat exchange a PutBitContext with libavcodec
via avpriv_align_put_bits and avpriv_copy_bits. So we can't really make
a 4.4 release.

- Andreas

>>
>> Found-by: Anton Khirnov 
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>   libavfilter/transform.c  | 23 +--
>>   libavfilter/transform.h  | 29 +
>>   libavfilter/vf_deshake.c |  5 +++--
>>   3 files changed, 5 insertions(+), 52 deletions(-)
>>
>> diff --git a/libavfilter/transform.c b/libavfilter/transform.c
>> index f4f9e0a47d..1f91436f73 100644
>> --- a/libavfilter/transform.c
>> +++ b/libavfilter/transform.c
>> @@ -122,28 +122,7 @@ void ff_get_matrix(
>>   matrix[8] = 1;
>>   }
>>   -void avfilter_add_matrix(const float *m1, const float *m2, float
>> *result)
>> -{
>> -    int i;
>> -    for (i = 0; i < 9; i++)
>> -    result[i] = m1[i] + m2[i];
>> -}
>> -
>> -void avfilter_sub_matrix(const float *m1, const float *m2, float
>> *result)
>> -{
>> -    int i;
>> -    for (i = 0; i < 9; i++)
>> -    result[i] = m1[i] - m2[i];
>> -}
>> -
>> -void avfilter_mul_matrix(const float *m1, float scalar, float *result)
>> -{
>> -    int i;
>> -    for (i = 0; i < 9; i++)
>> -    result[i] = m1[i] * scalar;
>> -}
>> -
>> -int avfilter_transform(const uint8_t *src, uint8_t *dst,
>> +int ff_affine_transform(const uint8_t *src, uint8_t *dst,
>>   int src_stride, int dst_stride,
>>   int width, int height, const float *matrix,
>>   enum InterpolateMethod interpolate,
>> diff --git a/libavfilter/transform.h b/libavfilter/transform.h
>> index 9b0c19ceca..0344f9c228 100644
>> --- a/libavfilter/transform.h
>> +++ b/libavfilter/transform.h
>> @@ -83,33 +83,6 @@ void ff_get_matrix(
>>   float *matrix
>>   );
>>   -/**
>> - * Add two matrices together. result = m1 + m2.
>> - *
>> - * @param m1 9-item transformation matrix
>> - * @param m2 9-item transformation matrix
>> - * @param result 9-item transformation matrix
>> - */
>> -void avfilter_add_matrix(const float *m1, const float *m2, float
>> *result);
>> -
>> -/**
>> - * Subtract one matrix from another. result = m1 - m2.
>> - *
>> - * @param m1 9-item transformation matrix
>> - * @param m2 9-item transformation matrix
>> - * @param result 9-item transformation matrix
>> - */
>> -void avfilter_sub_matrix(const float *m1, const float *m2, float
>> *result);
>> -
>> -/**
>> - * Multiply a matrix by a scalar value. result = m1 * scalar.
>> - *
>> - * @param m1 9-item transformation matrix
>> - * @param scalar a number
>> - * @param result 9-item transformation matrix
>> - */
>> -void avfilter_mul_matrix(const float *m1, float scalar, float *result);
>> -
>>   /**
>>    * Do an affine transformation with the given interpolation method.
>> This
>>    * multiplies each vector [x,y,1] by the matrix and then
>> interpolates to
>> @@ -126,7 +99,7 @@ void avfilter_mul_matrix(const float *m1, float
>> scalar, float *result);
>>    * @param fill    edge fill method
>>    * @return negative on error
>>    */
>> -int avfilter_transform(const uint8_t *src, uint8_t *dst,
>> +int ff_affine_transform(const uint8_t *src, uint8_t *dst,
>>   int src_stride, int dst_stride,
>>   int width, int height, const float *matrix,
>>   enum InterpolateMethod interpolate,
>> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
>> index 28a541b94a..8771399351 100644
>> --- a/libavfilter/vf_deshake.c
>> +++ b/libavfilter/vf_deshake.c
>> @@ -330,8 +330,9 @@ static int deshake_transform_c(AVFilterContext *ctx,
>>     for (i = 0; i < 3; i++) {
>>   // Transform the luma and chroma planes
>> -    ret = avfilter_transform(in->data[i], out->data[i],
>> in->linesize[i], out->linesize[i],
>> -  

Re: [FFmpeg-devel] [PATCH] filters/metadata: add CSV output support

2021-02-24 Thread Paul B Mahol
On Wed, Feb 24, 2021 at 9:48 PM Werner Robitza 
wrote:

> On Wed, Feb 24, 2021 at 9:11 PM Paul B Mahol  wrote:
> >
> > Why duplicating code that would give same output as ffprobe?
>
> I was told to here:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/275510.html
>
> Could please show an example on how to achieve this with ffprobe?
>

See same thread where I replied or use search.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/transform: Stop exporting internal functions

2021-02-24 Thread Paul B Mahol
On Thu, Feb 25, 2021 at 1:32 AM Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:

> James Almer:
> > On 2/24/2021 11:22 AM, Andreas Rheinhardt wrote:
> >> avfilter_transform, avfilter_(add|sub|mult)_matrix are not part of the
> >> public API (transform.h is not a public header), yet they are currently
> >> exported because of their name. This commit changes this:
> >> avfilter_transform is renamed to ff_affine_transform; the other
> >> functions are just removed as they have never been used at all.
> >
> > The symbols are exported and have been in four releases so far for this
> > soname. If we plan on making a 4.4 release before the bump, it may be a
> > good idea if we keep the symbols around for the sake of not affecting
> > the ABI, so I'm inclined towards just wrapping them in a
> > LIBAVFILTER_VERSION_MAJOR < 8 check like we do when we remove avpriv
> ones.
> >
>
> And why? There was never a legitimate outside user of these functions.
> And removing avfilter_all_channel_layouts in
> d5e5c6862bbc834d5a036a3fa053a7569d84f928 (which also didn't have a
> legitimate outside user) didn't seem to break anything either.
> Btw: 88d80cb97528d52dac3178cf5393d6095eca6200 broke ABI for x64, because
> older versions of libavformat exchange a PutBitContext with libavcodec
> via avpriv_align_put_bits and avpriv_copy_bits. So we can't really make
> a 4.4 release.
>

5.0 then

>
> - Andreas
>
> >>
> >> Found-by: Anton Khirnov 
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >>   libavfilter/transform.c  | 23 +--
> >>   libavfilter/transform.h  | 29 +
> >>   libavfilter/vf_deshake.c |  5 +++--
> >>   3 files changed, 5 insertions(+), 52 deletions(-)
> >>
> >> diff --git a/libavfilter/transform.c b/libavfilter/transform.c
> >> index f4f9e0a47d..1f91436f73 100644
> >> --- a/libavfilter/transform.c
> >> +++ b/libavfilter/transform.c
> >> @@ -122,28 +122,7 @@ void ff_get_matrix(
> >>   matrix[8] = 1;
> >>   }
> >>   -void avfilter_add_matrix(const float *m1, const float *m2, float
> >> *result)
> >> -{
> >> -int i;
> >> -for (i = 0; i < 9; i++)
> >> -result[i] = m1[i] + m2[i];
> >> -}
> >> -
> >> -void avfilter_sub_matrix(const float *m1, const float *m2, float
> >> *result)
> >> -{
> >> -int i;
> >> -for (i = 0; i < 9; i++)
> >> -result[i] = m1[i] - m2[i];
> >> -}
> >> -
> >> -void avfilter_mul_matrix(const float *m1, float scalar, float *result)
> >> -{
> >> -int i;
> >> -for (i = 0; i < 9; i++)
> >> -result[i] = m1[i] * scalar;
> >> -}
> >> -
> >> -int avfilter_transform(const uint8_t *src, uint8_t *dst,
> >> +int ff_affine_transform(const uint8_t *src, uint8_t *dst,
> >>   int src_stride, int dst_stride,
> >>   int width, int height, const float *matrix,
> >>   enum InterpolateMethod interpolate,
> >> diff --git a/libavfilter/transform.h b/libavfilter/transform.h
> >> index 9b0c19ceca..0344f9c228 100644
> >> --- a/libavfilter/transform.h
> >> +++ b/libavfilter/transform.h
> >> @@ -83,33 +83,6 @@ void ff_get_matrix(
> >>   float *matrix
> >>   );
> >>   -/**
> >> - * Add two matrices together. result = m1 + m2.
> >> - *
> >> - * @param m1 9-item transformation matrix
> >> - * @param m2 9-item transformation matrix
> >> - * @param result 9-item transformation matrix
> >> - */
> >> -void avfilter_add_matrix(const float *m1, const float *m2, float
> >> *result);
> >> -
> >> -/**
> >> - * Subtract one matrix from another. result = m1 - m2.
> >> - *
> >> - * @param m1 9-item transformation matrix
> >> - * @param m2 9-item transformation matrix
> >> - * @param result 9-item transformation matrix
> >> - */
> >> -void avfilter_sub_matrix(const float *m1, const float *m2, float
> >> *result);
> >> -
> >> -/**
> >> - * Multiply a matrix by a scalar value. result = m1 * scalar.
> >> - *
> >> - * @param m1 9-item transformation matrix
> >> - * @param scalar a number
> >> - * @param result 9-item transformation matrix
> >> - */
> >> -void avfilter_mul_matrix(const float *m1, float scalar, float *result);
> >> -
> >>   /**
> >>* Do an affine transformation with the given interpolation method.
> >> This
> >>* multiplies each vector [x,y,1] by the matrix and then
> >> interpolates to
> >> @@ -126,7 +99,7 @@ void avfilter_mul_matrix(const float *m1, float
> >> scalar, float *result);
> >>* @param filledge fill method
> >>* @return negative on error
> >>*/
> >> -int avfilter_transform(const uint8_t *src, uint8_t *dst,
> >> +int ff_affine_transform(const uint8_t *src, uint8_t *dst,
> >>   int src_stride, int dst_stride,
> >>   int width, int height, const float *matrix,
> >>   enum InterpolateMethod interpolate,
> >> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
> >> index 28a541b94a..8771399351 100644
> >> --- a/liba

Re: [FFmpeg-devel] [PATCH V3 3/3] libavfilter: add filter dnn_detect for object detection

2021-02-24 Thread Guo, Yejun


> -Original Message-
> From: Guo, Yejun 
> Sent: 2021年2月22日 15:31
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun 
> Subject: [PATCH V3 3/3] libavfilter: add filter dnn_detect for object 
> detection
> 
> Below are the example steps to do object detection:
> 
> 1. download and install l_openvino_toolkit_p_2021.1.110.tgz from
> https://software.intel.com/content/www/us/en/develop/tools/openvino-toolk
> it/download.html
>   or, we can get source code (tag 2021.1), build and install.
> 2. export LD_LIBRARY_PATH with openvino settings, for example:
> .../deployment_tools/inference_engine/lib/intel64/:.../deployment_tools/infer
> ence_engine/external/tbb/lib/
> 3. rebuild ffmpeg from source code with configure option:
> --enable-libopenvino
> --extra-cflags='-I.../deployment_tools/inference_engine/include/'
> --extra-ldflags='-L.../deployment_tools/inference_engine/lib/intel64'
> 4. download model files and test image
> wget
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.
> 1/face-detection-adas-0001.bin
> wget
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.
> 1/face-detection-adas-0001.xml
> wget
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.
> 1/face-detection-adas-0001.label
> wget https://github.com/guoyejun/ffmpeg_dnn/raw/main/images/cici.jpg
> 5. run ffmpeg with:
> ./ffmpeg -i cici.jpg -vf
> dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:inp
> ut=data:output=detection_out:confidence=0.6:labels=face-detection-adas-000
> 1.label -f null -
> 
> We'll see the detect result as below:
> [Parsed_dnn_detect_0 @ 0x56226644e540] frame->private_ref (bounding
> boxes):
> [Parsed_dnn_detect_0 @ 0x56226644e540] source:
> face-detection-adas-0001.xml
> [Parsed_dnn_detect_0 @ 0x56226644e540] index: 0, region: (1005, 813) ->
> (1086, 905), label: face, confidence: 1/1.
> [Parsed_dnn_detect_0 @ 0x56226644e540] index: 1, region: (888, 839) ->
> (967, 926), label: face, confidence: 6917/1.
> 
> There are two faces detected with confidence 100% and 69.17%.
> 
> Signed-off-by: Guo, Yejun 
> ---
>  configure  |   1 +
>  doc/filters.texi   |  40 +++
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/dnn/dnn_backend_openvino.c |  12 +
>  libavfilter/dnn_filter_common.c|   7 +
>  libavfilter/dnn_filter_common.h|   1 +
>  libavfilter/dnn_interface.h|   6 +-
>  libavfilter/vf_dnn_detect.c| 462
> +
>  9 files changed, 529 insertions(+), 2 deletions(-)  create mode 100644
> libavfilter/vf_dnn_detect.c
> 

any other comment for this patch set? thanks.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build warning

2021-02-24 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Guo,
> Yejun
> Sent: 2021年2月24日 23:15
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build warning
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> Anton
> > Khirnov
> > Sent: 2021年2月24日 22:05
> > To: FFmpeg development discussions and patches
> 
> > Subject: Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build 
> > warning
> >
> > Quoting Guo, Yejun (2021-02-20 08:22:11)
> > > Here is the warning message:
> > > src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
> > > src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be
> > truncated writing up to 255 bytes into a region of size 251
> > [-Wformat-truncation=]
> > >  snprintf(device_name, sizeof(device_name), "/dev/%s",
> > entry->d_name);
> > >   ^~
> > > src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261
> > bytes into a destination of size 256
> > >  snprintf(device_name, sizeof(device_name), "/dev/%s",
> > entry->d_name);
> > >
> > >
> >
> ^~~
> > ~
> > > ---
> > > This patch set fixes build warnings during make on my system with gcc
> > > version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) with config option:
> > > --disable-optimizations --enable-libx264 --enable-libx265 --enable-gpl
> > --enable-libvpx --enable-libmfx 
> > --extra-cflags="-Wno-deprecated-declarations"
> > >
> > > I also tried '-Wall -Werror', there are many many issues starting from
> > > configure. It is a long term task, let's fix one by one when have time.
> > >
> > >  libavdevice/v4l2.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index
> > > 365bacd771..15ade26eed 100644
> > > --- a/libavdevice/v4l2.c
> > > +++ b/libavdevice/v4l2.c
> > > @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext
> > *ctx, AVDeviceInfoList *device_l
> > >  return ret;
> > >  }
> > >  while ((entry = readdir(dir))) {
> > > -char device_name[256];
> > > +char device_name[261];
> >
> > sizeof(entry->d_name) + 5
> > would be eaiser to read IMO
> 
> yes, will update the patches, and send all with V2 except patch 7 which has
> been fixed with 1c9e53d7

just think we might better to use char device_name[512] which is more intuitive
and it reserves the memory (local variable) in case that the following code is 
changed to add more chars.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V2 1/7] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-24 Thread Guo, Yejun
Here is the warning message:
src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be truncated 
writing up to 255 bytes into a region of size 251 [-Wformat-truncation=]
 snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
  ^~
src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261 bytes 
into a destination of size 256
 snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
 ^~~~

Signed-off-by: Guo, Yejun 
---
 libavdevice/v4l2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 365bacd771..e11d10d20e 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, 
AVDeviceInfoList *device_l
 return ret;
 }
 while ((entry = readdir(dir))) {
-char device_name[256];
+char device_name[512];
 
 if (!v4l2_is_v4l_dev(entry->d_name))
 continue;
-- 
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 V2 2/7] libavfilter/vf_ssim.c: fix build warning for [-Wmain]

2021-02-24 Thread Guo, Yejun
The build warning message:
src/libavfilter/vf_ssim.c: In function ‘ssim_plane_16bit’:
src/libavfilter/vf_ssim.c:246:24: warning: ‘main’ is usually a function [-Wmain]
 const uint8_t *main = td->main_data[c];
^~~~
src/libavfilter/vf_ssim.c: In function ‘ssim_plane’:
src/libavfilter/vf_ssim.c:289:24: warning: ‘main’ is usually a function [-Wmain]
 const uint8_t *main = td->main_data[c];
^~~~

Signed-off-by: Guo, Yejun 
---
 libavfilter/vf_ssim.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index 9682c093b2..ebb314c69f 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -243,8 +243,8 @@ static int ssim_plane_16bit(AVFilterContext *ctx, void *arg,
 const int max = td->max;
 
 for (int c = 0; c < td->nb_components; c++) {
-const uint8_t *main = td->main_data[c];
-const uint8_t *ref = td->ref_data[c];
+const uint8_t *main_data = td->main_data[c];
+const uint8_t *ref_data = td->ref_data[c];
 const int main_stride = td->main_linesize[c];
 const int ref_stride = td->ref_linesize[c];
 int width = td->planewidth[c];
@@ -263,8 +263,8 @@ static int ssim_plane_16bit(AVFilterContext *ctx, void *arg,
 for (int y = ystart; y < slice_end; y++) {
 for (; z <= y; z++) {
 FFSWAP(void*, sum0, sum1);
-ssim_4x4xn_16bit(&main[4 * z * main_stride], main_stride,
- &ref[4 * z * ref_stride], ref_stride,
+ssim_4x4xn_16bit(&main_data[4 * z * main_stride], main_stride,
+ &ref_data[4 * z * ref_stride], ref_stride,
  sum0, width);
 }
 
@@ -286,8 +286,8 @@ static int ssim_plane(AVFilterContext *ctx, void *arg,
 SSIMDSPContext *dsp = td->dsp;
 
 for (int c = 0; c < td->nb_components; c++) {
-const uint8_t *main = td->main_data[c];
-const uint8_t *ref = td->ref_data[c];
+const uint8_t *main_data = td->main_data[c];
+const uint8_t *ref_data = td->ref_data[c];
 const int main_stride = td->main_linesize[c];
 const int ref_stride = td->ref_linesize[c];
 int width = td->planewidth[c];
@@ -306,8 +306,8 @@ static int ssim_plane(AVFilterContext *ctx, void *arg,
 for (int y = ystart; y < slice_end; y++) {
 for (; z <= y; z++) {
 FFSWAP(void*, sum0, sum1);
-dsp->ssim_4x4_line(&main[4 * z * main_stride], main_stride,
-   &ref[4 * z * ref_stride], ref_stride,
+dsp->ssim_4x4_line(&main_data[4 * z * main_stride], 
main_stride,
+   &ref_data[4 * z * ref_stride], ref_stride,
sum0, width);
 }
 
-- 
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 V2 3/7] libavfilter/vf_vif.c: fix build warning for [-Wmain]

2021-02-24 Thread Guo, Yejun
src/libavfilter/vf_vif.c: In function ‘process_frame’:
src/libavfilter/vf_vif.c:542:20: warning: ‘main’ is usually a function [-Wmain]
 AVFrame *out, *main = NULL, *ref = NULL;
^~~~

Signed-off-by: Guo, Yejun 
---
 libavfilter/vf_vif.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_vif.c b/libavfilter/vf_vif.c
index 876c7c9120..0bd71eca5c 100644
--- a/libavfilter/vf_vif.c
+++ b/libavfilter/vf_vif.c
@@ -539,22 +539,22 @@ static int process_frame(FFFrameSync *fs)
 AVFilterContext *ctx = fs->parent;
 VIFContext *s = fs->opaque;
 AVFilterLink *outlink = ctx->outputs[0];
-AVFrame *out, *main = NULL, *ref = NULL;
+AVFrame *out_frame, *main_frame = NULL, *ref_frame = NULL;
 int ret;
 
-ret = ff_framesync_dualinput_get(fs, &main, &ref);
+ret = ff_framesync_dualinput_get(fs, &main_frame, &ref_frame);
 if (ret < 0)
 return ret;
 
-if (ctx->is_disabled || !ref) {
-out = main;
+if (ctx->is_disabled || !ref_frame) {
+out_frame = main_frame;
 } else {
-out = do_vif(ctx, main, ref);
+out_frame = do_vif(ctx, main_frame, ref_frame);
 }
 
-out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+out_frame->pts = av_rescale_q(s->fs.pts, s->fs.time_base, 
outlink->time_base);
 
-return ff_filter_frame(outlink, out);
+return ff_filter_frame(outlink, out_frame);
 }
 
 
-- 
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 V2 4/7] libavformat/dashenc.c: fix build warning for [-Wformat-truncation=]

2021-02-24 Thread Guo, Yejun
Part of warning message:
src/libavformat/dashenc.c: In function ‘flush_init_segment’:
src/libavformat/dashenc.c:608:49: warning: ‘%s’ directive output may be 
truncated writing up to 1023 bytes into a region of size between 1 and 1024 
[-Wformat-truncation=]
 snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
 ^~
src/libavformat/dashenc.c:608:9: note: ‘snprintf’ output between 1 and 2047 
bytes into a destination of size 1024
 snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
 ^~

Signed-off-by: Guo, Yejun 
---
 libavformat/dashenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 2d757b3a87..b11f79c966 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -126,7 +126,7 @@ typedef struct OutputStream {
 char codec_str[100];
 int written_len;
 char filename[1024];
-char full_path[1024];
+char full_path[2048];
 char temp_path[1024];
 double availability_time_offset;
 AVProducerReferenceTime producer_reference_time;
@@ -604,7 +604,7 @@ static int flush_init_segment(AVFormatContext *s, 
OutputStream *os)
 
 os->pos = os->init_range_length = range_length;
 if (!c->single_file) {
-char filename[1024];
+char filename[2048];
 snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
 dashenc_io_close(s, &os->out, filename);
 }
@@ -1480,7 +1480,7 @@ static int dash_init(AVFormatContext *s)
 AVFormatContext *ctx;
 AVStream *st;
 AVDictionary *opts = NULL;
-char filename[1024];
+char filename[2048];
 
 os->bit_rate = s->streams[i]->codecpar->bit_rate;
 if (!os->bit_rate) {
-- 
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 V2 7/7] libavutil/opt.c: fix build warning for [-Wdiscarded-qualifiers]

2021-02-24 Thread Guo, Yejun
src/libavutil/opt.c: In function ‘av_opt_child_class_iterate’:
src/libavutil/opt.c:1738:15: warning: assignment discards ‘const’ qualifier 
from pointer target type [-Wdiscarded-qualifiers]
 *iter = parent->child_class_next(*iter);
   ^

Signed-off-by: Guo, Yejun 
---
 libavutil/opt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 590146b5fb..c47146c47f 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1735,7 +1735,7 @@ const AVClass *av_opt_child_class_iterate(const AVClass 
*parent, void **iter)
 #if FF_API_CHILD_CLASS_NEXT
 FF_DISABLE_DEPRECATION_WARNINGS
 if (parent->child_class_next) {
-*iter = parent->child_class_next(*iter);
+*iter = (void *)parent->child_class_next(*iter);
 return *iter;
 }
 FF_ENABLE_DEPRECATION_WARNINGS
-- 
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 V2 5/7] libavformat/protocols.c: fix build warning for [-Wdiscarded-qualifiers]

2021-02-24 Thread Guo, Yejun
src/libavformat/protocols.c: In function ‘avio_enum_protocols’:
src/libavformat/protocols.c:116:7: warning: assignment discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
 p = p ? p + 1 : url_protocols;
   ^

Signed-off-by: Guo, Yejun 
---
 libavformat/protocols.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 7df18fbb3b..86cde84a31 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -113,7 +113,7 @@ const char *avio_enum_protocols(void **opaque, int output)
 {
 const URLProtocol **p = *opaque;
 
-p = p ? p + 1 : url_protocols;
+p = p ? p + 1 : (const URLProtocol **)url_protocols;
 *opaque = p;
 if (!*p) {
 *opaque = NULL;
-- 
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 V2 6/7] libavformat/smoothstreamingenc.c: fix build warning for [-Wformat-truncation=]

2021-02-24 Thread Guo, Yejun
Part of the build message:
src/libavformat/smoothstreamingenc.c: In function ‘ism_flush’:
src/libavformat/smoothstreamingenc.c:510:49: warning: ‘/temp’ directive output 
may be truncated writing 5 bytes into a region of size between 1 and 1024 
[-Wformat-truncation=]
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^
src/libavformat/smoothstreamingenc.c:510:9: note: ‘snprintf’ output between 6 
and 1029 bytes into a destination of size 1024
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^~~~
src/libavformat/smoothstreamingenc.c:538:53: warning: ‘/temp’ directive output 
may be truncated writing 5 bytes into a region of size between 1 and 1024 
[-Wformat-truncation=]
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^
src/libavformat/smoothstreamingenc.c:538:13: note: ‘snprintf’ output between 6 
and 1029 bytes into a destination of size 1024
 snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
 ^~~~
src/libavformat/smoothstreamingenc.c:545:63: warning: ‘/FragmentInfo(’ 
directive output may be truncated writing 14 bytes into a region of size 
between 1 and 1024 [-Wformat-truncation=]
 snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
   ^~
src/libavformat/smoothstreamingenc.c:545:60: note: using the range [0, 
18446744073709551615] for directive argument
 snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);

^~
src/libavformat/smoothstreamingenc.c:545:9: note: ‘snprintf’ output 18 or more 
bytes (assuming 1041) into a destination of size 1024
 snprintf(header_filename, sizeof(header_filename), 
"%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
 
^~~

Signed-off-by: Guo, Yejun 
---
 libavformat/smoothstreamingenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index ba5cc27ca0..5a9a5dddf0 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -501,7 +501,7 @@ static int ism_flush(AVFormatContext *s, int final)
 
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = &c->streams[i];
-char filename[1024], target_filename[1024], header_filename[1024], 
curr_dirname[1024];
+char filename[2048], target_filename[2048], header_filename[2048], 
curr_dirname[1024];
 int64_t size;
 int64_t start_ts, duration, moof_size;
 if (!os->packets_written)
-- 
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".