Re: [FFmpeg-devel] [PATCH 01/11] avcodec/prosumer: Remove dead code
On 9/22/18, Michael Niedermayer wrote: > On Sat, Sep 22, 2018 at 06:24:14PM +0200, Paul B Mahol wrote: >> On 9/22/18, Michael Niedermayer wrote: >> > Signed-off-by: Michael Niedermayer >> > --- >> > libavcodec/prosumer.c | 3 --- >> > 1 file changed, 3 deletions(-) >> > >> > diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c >> > index a2932852c9..e6959bfb6c 100644 >> > --- a/libavcodec/prosumer.c >> > +++ b/libavcodec/prosumer.c >> > @@ -322,9 +322,6 @@ static void fill_lut(uint32_t *lut) >> > uint32_t b = a & 0xFFu; >> > uint32_t c, d, e; >> > >> > -if (b > 3) >> > -continue; >> > - >> > c = (b << 16) | table[i-1]; >> > d = 4 * (3 - b); >> > e = (((0xFFF0u << d) & a) >> 20) & 0xFFF; >> > -- >> > 2.19.0 >> > >> > ___ >> > ffmpeg-devel mailing list >> > ffmpeg-devel@ffmpeg.org >> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > >> >> LGTM whole patchset. >> >> I assuming all files we have still decodes fine after this applied. > > the 2 files i found decode unchanged > > i also had some sloppy checksum code locally to confirm that the LUT did > not > change from any commit: > @@ -332,6 +332,13 @@ static void fill_lut(uint32_t *lut) > lut[i ] = 0x68000; > lut[i+1] = 0; > } > + > +uint64_t R = 1; > +for (int i = 0; i<0x1; i++) { > +R += lut[i]; > +R *= 12345987517121; > +} > +av_assert0(R == -4720894470766836899); > } > > static av_cold int decode_init(AVCodecContext *avctx) > > [...] Should be fine. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 01/11] avcodec/prosumer: Remove dead code
On Sun, Sep 23, 2018 at 01:30:29PM +0200, Paul B Mahol wrote: > On 9/22/18, Michael Niedermayer wrote: > > On Sat, Sep 22, 2018 at 06:24:14PM +0200, Paul B Mahol wrote: > >> On 9/22/18, Michael Niedermayer wrote: > >> > Signed-off-by: Michael Niedermayer > >> > --- > >> > libavcodec/prosumer.c | 3 --- > >> > 1 file changed, 3 deletions(-) > >> > > >> > diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c > >> > index a2932852c9..e6959bfb6c 100644 > >> > --- a/libavcodec/prosumer.c > >> > +++ b/libavcodec/prosumer.c > >> > @@ -322,9 +322,6 @@ static void fill_lut(uint32_t *lut) > >> > uint32_t b = a & 0xFFu; > >> > uint32_t c, d, e; > >> > > >> > -if (b > 3) > >> > -continue; > >> > - > >> > c = (b << 16) | table[i-1]; > >> > d = 4 * (3 - b); > >> > e = (((0xFFF0u << d) & a) >> 20) & 0xFFF; > >> > -- > >> > 2.19.0 > >> > > >> > ___ > >> > ffmpeg-devel mailing list > >> > ffmpeg-devel@ffmpeg.org > >> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > > >> > >> LGTM whole patchset. > >> > >> I assuming all files we have still decodes fine after this applied. > > > > the 2 files i found decode unchanged > > > > i also had some sloppy checksum code locally to confirm that the LUT did > > not > > change from any commit: > > @@ -332,6 +332,13 @@ static void fill_lut(uint32_t *lut) > > lut[i ] = 0x68000; > > lut[i+1] = 0; > > } > > + > > +uint64_t R = 1; > > +for (int i = 0; i<0x1; i++) { > > +R += lut[i]; > > +R *= 12345987517121; > > +} > > +av_assert0(R == -4720894470766836899); > > } > > > > static av_cold int decode_init(AVCodecContext *avctx) > > > > [...] > > Should be fine. will apply thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] cache: read ahead to avoid excessive small requests
On Sat, Sep 22, 2018 at 07:32:28PM +0200, Robert Nagy wrote: > diff --git a/libavformat/cache.c b/libavformat/cache.c > index 66bbbf54c9..48ff5ab363 100644 > --- a/libavformat/cache.c > +++ b/libavformat/cache.c > @@ -153,6 +153,38 @@ fail: > return ret; > } > > +static int cache_read_ahead(URLContext *h) > +{ > +Context *c= h->priv_data; > +int64_t r, read_ahead, pos; > +uint8_t buf[32768]; > + > +pos = c->logical_pos; > +read_ahead = c->read_ahead_limit < 0 > +? 512 * 512 > +: FFMIN(512 * 512, c->read_ahead_limit); > + > +while (read_ahead > 0) { > +r = ffurl_read(c->inner, buf, FFMIN(read_ahead, sizeof(buf))); > +if (r == AVERROR_EOF) { > +c->is_true_eof = 1; > +av_assert0(c->end >= c->logical_pos); > +} > +if (r<=0) > +break; > +c->inner_pos += r; > + > +add_entry(h, buf, r); > +c->logical_pos += r; > +c->end = FFMAX(c->end, c->logical_pos); > +read_ahead -= r; > +} > + > +c->logical_pos = pos; > + > +return r < 0 ? r : 0; > +} > + > static int cache_read(URLContext *h, unsigned char *buf, int size) > { > Context *c= h->priv_data; > @@ -215,6 +247,10 @@ static int cache_read(URLContext *h, unsigned > char *buf, int size) still not cleanly applying (due to new lines) Applying: cache: read ahead to avoid excessive small requests error: corrupt patch at line 45 error: could not build fake ancestor Patch failed at 0001 cache: read ahead to avoid excessive small requests hint: Use 'git am --show-current-patch' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v4 00/38] VAAPI encode and related stuff
On 18/09/18 23:30, Mark Thompson wrote: > 1-28 should be complete and had only a few very minor changes since last > time. I'll push them this weekend if there are no further comments. (17 is > new but hopefully obvious.) These applied. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH V2] avcodec/vaapi:free slice_buffers when decoding failed
On 19/09/18 03:01, Linjie Fu wrote: > If vaEndPicture failed in ff_vaapi_decode_issue, free > the pic->slice_buffer. > > Fix the memory leak issue in ticket #7385 > > [V2] unit the return paths under the "exit" tag at > the end of the function. > > Signed-off-by: Linjie Fu > --- > libavcodec/vaapi_decode.c | 15 --- > 1 file changed, 8 insertions(+), 7 deletions(-) Tested and applied. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avdevice/decklink: add support for selecting devices based on their unique ID
On Sat, 22 Sep 2018, Jeyapal, Karthick wrote: On 9/21/18 5:10 PM, Marton Balint wrote: On Fri, 21 Sep 2018, Jeyapal, Karthick wrote: On 9/21/18 3:35 AM, Marton Balint wrote: Also bump the API version requirement to 10.9.5, because on olders versions there were some reports of crashes using the undocumented, yet available BMDDeckLinkDeviceHandle. If we are using an undocumented API feature, then there is a higher risk of this feature not working in some future versions of DeckLink drivers as well. I would suggest using this undocumented API call under an 'if' condition, which is controlled by a command line option for selecting based on unique ID. In that way setups which prefers stability can choose to not use this feature. It got documented in 10.10, so this is no longer an issue. I tested it with 10.9.10 as there were (non-related) regressions in 10.10, and it worked fine there, so I figured it should be OK to require only 10.9. If you still think using a non-documented feature is shady, I can bump the requirement to 10.10. Thanks for the clarification. In that case the current patch is fine, since you have testing it for 10.9. Thanks, applied. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] cache: read ahead to avoid excessive small requests
On Sun, Sep 23, 2018 at 1:40 PM Michael Niedermayer wrote: > > On Sat, Sep 22, 2018 at 07:32:28PM +0200, Robert Nagy wrote: > > diff --git a/libavformat/cache.c b/libavformat/cache.c > > index 66bbbf54c9..48ff5ab363 100644 > > --- a/libavformat/cache.c > > +++ b/libavformat/cache.c > > @@ -153,6 +153,38 @@ fail: > > return ret; > > } > > > > +static int cache_read_ahead(URLContext *h) > > +{ > > +Context *c= h->priv_data; > > +int64_t r, read_ahead, pos; > > +uint8_t buf[32768]; > > + > > +pos = c->logical_pos; > > +read_ahead = c->read_ahead_limit < 0 > > +? 512 * 512 > > +: FFMIN(512 * 512, c->read_ahead_limit); > > + > > +while (read_ahead > 0) { > > +r = ffurl_read(c->inner, buf, FFMIN(read_ahead, sizeof(buf))); > > +if (r == AVERROR_EOF) { > > +c->is_true_eof = 1; > > +av_assert0(c->end >= c->logical_pos); > > +} > > +if (r<=0) > > +break; > > +c->inner_pos += r; > > + > > +add_entry(h, buf, r); > > +c->logical_pos += r; > > +c->end = FFMAX(c->end, c->logical_pos); > > +read_ahead -= r; > > +} > > + > > +c->logical_pos = pos; > > + > > +return r < 0 ? r : 0; > > +} > > + > > static int cache_read(URLContext *h, unsigned char *buf, int size) > > { > > Context *c= h->priv_data; > > > @@ -215,6 +247,10 @@ static int cache_read(URLContext *h, unsigned > > char *buf, int size) > > still not cleanly applying (due to new lines) > > Applying: cache: read ahead to avoid excessive small requests > error: corrupt patch at line 45 > error: could not build fake ancestor > Patch failed at 0001 cache: read ahead to avoid excessive small requests > hint: Use 'git am --show-current-patch' to see the failed patch > When you have resolved this problem, run "git am --continue". > If you prefer to skip this patch, run "git am --skip" instead. > To restore the original branch and stop patching, run "git am --abort". > > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > The greatest way to live with honor in this world is to be what we pretend > to be. -- Socrates > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 0001-cache-read-ahead-to-avoid-excessive-small-requests.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] libavdevice/decklink trivial patch for SDI input/output
On Thu, 6 Sep 2018, Baldur Gislason wrote: Sending this again as the mime type was wrong for the patch on the last message. I have prepared a patch that adds two things. On the Decklink input side, it adds a parameter called 'passthrough' which makes it possible to change from the default behaviour on cards that can handle both inputs and outputs. The default behaviour on such cards depends on the model but many of them will pass through the input signal if the application generating the output stops. This is not always desirable so the Decklink API provides a method of changing it. On the output side, it adds a parameter called 'sdi_link' which is crucial when working with SDI output cards that support 3G SDI or faster. The default behaviour for 1080p60 for example is to use two HD-SDI links and the default for 2160p29.97 is to use four HD-SDI links. This option makes it possible to specify how many SDI links are to be used to make use of 3G, 6G or 12G SDI capabilities of newer cards which can output those configurations over a single cable. Thanks, could you please update docs/indevs.texi and docs/outdevs.texi with the new options? Also please check the indentation inside the switch() {} sections. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file
On Sat, Sep 22, 2018 at 11:53:22PM +0200, Marton Balint wrote: > These are based on the very similar UDP and RTP protocol functions. > > Signed-off-by: Marton Balint > --- > libavformat/ip.c | 165 > +++ > libavformat/ip.h | 74 + > 2 files changed, 239 insertions(+) > create mode 100644 libavformat/ip.c > create mode 100644 libavformat/ip.h [...] > +/** > + * Parses the address[,address] source list in buf and adds it to the filters > + * in the IPSourceFilters structure. > + * @param buf is the source list, which is not changed, but must be writable > + * @return 0 on success, < 0 AVERROR code on error. > + */ > +int ff_ip_parse_sources(void *log_ctx, char *buf, IPSourceFilters *filters); > + > +/** > + * Parses the address[,address] source block list in buf and adds it to the > + * filters in the IPSourceFilters structure. > + * @param buf is the source list, which is not changed, but must be writable if its not changed, why does it need to be writable ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 1/5] vaapi_encode: Support configurable slices
This adds common code to query driver support and set appropriate address/size information for each slice. It only supports rectangular slices for now, since that is the most common use-case. --- doc/encoders.texi | 2 + libavcodec/vaapi_encode.c | 151 +- libavcodec/vaapi_encode.h | 22 ++ 3 files changed, 173 insertions(+), 2 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 8d184f72f8..899faac49b 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2598,6 +2598,8 @@ Size / quality tradeoff: higher values are smaller / worse quality. @option{b_qfactor} / @option{b_quant_factor} @item @option{b_qoffset} / @option{b_quant_offset} +@item +@option{slices} @end itemize All encoders support the following options: diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2c34cdce2c..2d33aa5ec3 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -319,16 +319,60 @@ static int vaapi_encode_issue(AVCodecContext *avctx, } } +if (pic->nb_slices == 0) +pic->nb_slices = ctx->nb_slices; if (pic->nb_slices > 0) { +int rounding; + pic->slices = av_mallocz_array(pic->nb_slices, sizeof(*pic->slices)); if (!pic->slices) { err = AVERROR(ENOMEM); goto fail; } + +for (i = 0; i < pic->nb_slices; i++) +pic->slices[i].row_size = ctx->slice_size; + +rounding = ctx->slice_block_rows - ctx->nb_slices * ctx->slice_size; +if (rounding > 0) { +// Place rounding error at top and bottom of frame. +av_assert0(rounding < pic->nb_slices); +// Some Intel drivers contain a bug where the encoder will fail +// if the last slice is smaller than the one before it. Since +// that's straightforward to avoid here, just do so. +if (rounding <= 2) { +for (i = 0; i < rounding; i++) +++pic->slices[i].row_size; +} else { +for (i = 0; i < (rounding + 1) / 2; i++) +++pic->slices[pic->nb_slices - i - 1].row_size; +for (i = 0; i < rounding / 2; i++) +++pic->slices[i].row_size; +} +} else if (rounding < 0) { +// Remove rounding error from last slice only. +av_assert0(rounding < ctx->slice_size); +pic->slices[pic->nb_slices - 1].row_size += rounding; +} } for (i = 0; i < pic->nb_slices; i++) { slice = &pic->slices[i]; slice->index = i; +if (i == 0) { +slice->row_start = 0; +slice->block_start = 0; +} else { +const VAAPIEncodeSlice *prev = &pic->slices[i - 1]; +slice->row_start = prev->row_start + prev->row_size; +slice->block_start = prev->block_start + prev->block_size; +} +slice->block_size = slice->row_size * ctx->slice_block_cols; + +av_log(avctx, AV_LOG_DEBUG, "Slice %d: %d-%d (%d rows), " + "%d-%d (%d blocks).\n", i, slice->row_start, + slice->row_start + slice->row_size - 1, slice->row_size, + slice->block_start, slice->block_start + slice->block_size - 1, + slice->block_size); if (ctx->codec->slice_params_size > 0) { slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size); @@ -1014,8 +1058,7 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx) VAEntrypoint *va_entrypoints = NULL; VAStatus vas; const VAEntrypoint *usable_entrypoints; -const VAAPIEncodeProfile *profile; -const AVPixFmtDescriptor *desc; +const VAAPIEncodeProfile *profile;const AVPixFmtDescriptor *desc; VAConfigAttrib rt_format_attr; const VAAPIEncodeRTFormat *rt_format; const char *profile_string, *entrypoint_string; @@ -1444,6 +1487,106 @@ static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx) return 0; } +static av_cold int vaapi_encode_init_slice_structure(AVCodecContext *avctx) +{ +VAAPIEncodeContext *ctx = avctx->priv_data; +VAConfigAttrib attr[2] = { { VAConfigAttribEncMaxSlices }, + { VAConfigAttribEncSliceStructure } }; +VAStatus vas; +uint32_t max_slices, slice_structure; +int req_slices; + +if (!(ctx->codec->flags & FLAG_SLICE_CONTROL)) { +if (avctx->slices > 0) { +av_log(avctx, AV_LOG_WARNING, "Multiple slices were requested " + "but this codec does not support controlling slices.\n"); +} +return 0; +} + +ctx->slice_block_rows = (avctx->height + ctx->slice_block_height - 1) / + ctx->slice_block_height; +ctx->slice_block_cols = (avctx->width + ctx->slice_block_width - 1) / + ctx->
[FFmpeg-devel] [PATCH v2 2/5] vaapi_encode_mpeg2: Use common slice sizing code
--- libavcodec/vaapi_encode_mpeg2.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index 1377eeb9bb..99a8b43237 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -35,9 +35,6 @@ typedef struct VAAPIEncodeMPEG2Context { int level; // Derived settings. -int mb_width; -int mb_height; - int quant_i; int quant_p; int quant_b; @@ -477,8 +474,6 @@ static int vaapi_encode_mpeg2_init_picture_params(AVCodecContext *avctx, vpic->f_code[1][0] = pce->f_code[1][0]; vpic->f_code[1][1] = pce->f_code[1][1]; -pic->nb_slices = priv->mb_height; - return 0; } @@ -490,8 +485,8 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx, VAEncSliceParameterBufferMPEG2 *vslice = slice->codec_slice_params; int qp; -vslice->macroblock_address = priv->mb_width * slice->index; -vslice->num_macroblocks= priv->mb_width; +vslice->macroblock_address = slice->block_start; +vslice->num_macroblocks= slice->block_size; switch (pic->type) { case PICTURE_TYPE_IDR: @@ -525,9 +520,6 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) if (err < 0) return err; -priv->mb_width = FFALIGN(avctx->width, 16) / 16; -priv->mb_height = FFALIGN(avctx->height, 16) / 16; - if (ctx->va_rc_mode == VA_RC_CQP) { priv->quant_p = av_clip(avctx->global_quality, 1, 31); if (avctx->i_quant_factor > 0.0) @@ -553,6 +545,12 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) av_assert0(0 && "Invalid RC mode."); } +ctx->slice_block_rows = FFALIGN(avctx->width, 16) / 16; +ctx->slice_block_cols = FFALIGN(avctx->height, 16) / 16; + +ctx->nb_slices = ctx->slice_block_rows; +ctx->slice_size = 1; + return 0; } -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 5/5] vaapi_encode: Add flag to mark encoders supporting only constant-quality
And set it for MJPEG. --- libavcodec/vaapi_encode.c | 3 ++- libavcodec/vaapi_encode.h | 2 ++ libavcodec/vaapi_encode_mjpeg.c | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2d33aa5ec3..bc1cad7395 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1276,7 +1276,8 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) ctx->va_rc_mode = VA_RC_CQP; return 0; } -if (avctx->flags & AV_CODEC_FLAG_QSCALE || +if (ctx->codec->flags & FLAG_CONSTANT_QUALITY_ONLY || +avctx->flags & AV_CODEC_FLAG_QSCALE || avctx->bit_rate <= 0) { if (rc_attr.value & VA_RC_CQP) { av_log(avctx, AV_LOG_VERBOSE, "Using constant-quality mode.\n"); diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 271d4ef518..965fe65c0b 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -251,6 +251,8 @@ typedef struct VAAPIEncodeContext { enum { // Codec supports controlling the subdivision of pictures into slices. FLAG_SLICE_CONTROL = 1 << 0, +// Codec only supports constant quality (no rate control). +FLAG_CONSTANT_QUALITY_ONLY = 1 << 1, }; typedef struct VAAPIEncodeType { diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index fe8439ce88..79f43473f5 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -476,6 +476,8 @@ static const VAAPIEncodeProfile vaapi_encode_mjpeg_profiles[] = { static const VAAPIEncodeType vaapi_encode_type_mjpeg = { .profiles = vaapi_encode_mjpeg_profiles, +.flags = FLAG_CONSTANT_QUALITY_ONLY, + .configure = &vaapi_encode_mjpeg_configure, .picture_params_size = sizeof(VAEncPictureParameterBufferJPEG), -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 3/5] vaapi_encode_h264: Enable multiple-slice support
--- libavcodec/vaapi_encode_h264.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 8feae0d42f..7bb77cfba2 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -733,8 +733,6 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, vpic->pic_fields.bits.idr_pic_flag = (pic->type == PICTURE_TYPE_IDR); vpic->pic_fields.bits.reference_pic_flag = (pic->type != PICTURE_TYPE_B); -pic->nb_slices = 1; - return 0; } @@ -758,8 +756,7 @@ static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx, sh->nal_unit_header.nal_ref_idc = pic->type != PICTURE_TYPE_B; } -// Only one slice per frame. -sh->first_mb_in_slice = 0; +sh->first_mb_in_slice = slice->block_start; sh->slice_type= priv->slice_type; sh->pic_parameter_set_id = pps->pic_parameter_set_id; @@ -780,8 +777,8 @@ static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx, sh->slice_qp_delta = priv->fixed_qp_idr - (pps->pic_init_qp_minus26 + 26); -vslice->macroblock_address = sh->first_mb_in_slice; -vslice->num_macroblocks= priv->mb_width * priv->mb_height; +vslice->macroblock_address = slice->block_start; +vslice->num_macroblocks= slice->block_size; vslice->macroblock_info = VA_INVALID_ID; @@ -903,6 +900,8 @@ static const VAAPIEncodeProfile vaapi_encode_h264_profiles[] = { static const VAAPIEncodeType vaapi_encode_type_h264 = { .profiles = vaapi_encode_h264_profiles, +.flags = FLAG_SLICE_CONTROL, + .configure = &vaapi_encode_h264_configure, .sequence_params_size = sizeof(VAEncSequenceParameterBufferH264), @@ -978,6 +977,8 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx) ctx->surface_width = FFALIGN(avctx->width, 16); ctx->surface_height = FFALIGN(avctx->height, 16); +ctx->slice_block_height = ctx->slice_block_width = 16; + return ff_vaapi_encode_init(avctx); } -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v2 4/5] vaapi_encode_h265: Enable multiple-slice support
--- libavcodec/vaapi_encode_h265.c | 26 +- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 1ada973dd3..ddda9165fa 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -54,9 +54,6 @@ typedef struct VAAPIEncodeH265Context { int sei; // Derived settings. -unsigned int ctu_width; -unsigned int ctu_height; - int fixed_qp_idr; int fixed_qp_p; int fixed_qp_b; @@ -849,8 +846,6 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, av_assert0(0 && "invalid picture type"); } -pic->nb_slices = 1; - return 0; } @@ -875,9 +870,8 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, sh->slice_pic_parameter_set_id = pps->pps_pic_parameter_set_id; -// Currently we only support one slice per frame. -sh->first_slice_segment_in_pic_flag = 1; -sh->slice_segment_address = 0; +sh->first_slice_segment_in_pic_flag = slice->index == 0; +sh->slice_segment_address = slice->block_start; sh->slice_type = priv->slice_type; @@ -967,7 +961,7 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, *vslice = (VAEncSliceParameterBufferHEVC) { .slice_segment_address = sh->slice_segment_address, -.num_ctu_in_slice = priv->ctu_width * priv->ctu_height, +.num_ctu_in_slice = slice->block_size, .slice_type = sh->slice_type, .slice_pic_parameter_set_id = sh->slice_pic_parameter_set_id, @@ -988,7 +982,7 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, .slice_tc_offset_div2 = sh->slice_tc_offset_div2, .slice_fields.bits = { -.last_slice_of_pic_flag = 1, +.last_slice_of_pic_flag = slice->index == pic->nb_slices - 1, .dependent_slice_segment_flag = sh->dependent_slice_segment_flag, .colour_plane_id = sh->colour_plane_id, .slice_temporal_mvp_enabled_flag = @@ -1040,13 +1034,6 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) if (err < 0) return err; -priv->ctu_width = FFALIGN(ctx->surface_width, 32) / 32; -priv->ctu_height= FFALIGN(ctx->surface_height, 32) / 32; - -av_log(avctx, AV_LOG_VERBOSE, "Input %ux%u -> Surface %ux%u -> CTU %ux%u.\n", - avctx->width, avctx->height, ctx->surface_width, - ctx->surface_height, priv->ctu_width, priv->ctu_height); - if (ctx->va_rc_mode == VA_RC_CQP) { priv->fixed_qp_p = priv->qp; if (avctx->i_quant_factor > 0.0) @@ -1091,6 +1078,8 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { static const VAAPIEncodeType vaapi_encode_type_h265 = { .profiles = vaapi_encode_h265_profiles, +.flags = FLAG_SLICE_CONTROL, + .configure = &vaapi_encode_h265_configure, .sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC), @@ -1137,6 +1126,9 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) ctx->surface_width = FFALIGN(avctx->width, 16); ctx->surface_height = FFALIGN(avctx->height, 16); +// CTU size is currently hard-coded to 32. +ctx->slice_block_width = ctx->slice_block_height = 32; + return ff_vaapi_encode_init(avctx); } -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] configure: fix --disable-alsa after 247281e805
1 && 2 || 3 is implicitly grouped as { 1 && 2; } || 3 as both && and || have equal precedence and are evaluated with left associativity. Signed-off-by: Jan Beich --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 1946bcb69c..ea6fa2c6dc 100755 --- a/configure +++ b/configure @@ -6331,8 +6331,10 @@ else EOF fi -enabled alsa && check_pkg_config alsa alsa "alsa/asoundlib.h" snd_pcm_htimestamp || +if enabled alsa; then +check_pkg_config alsa alsa "alsa/asoundlib.h" snd_pcm_htimestamp || check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound +fi enabled libjack && require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file
On Sun, 23 Sep 2018, Michael Niedermayer wrote: On Sat, Sep 22, 2018 at 11:53:22PM +0200, Marton Balint wrote: These are based on the very similar UDP and RTP protocol functions. Signed-off-by: Marton Balint --- libavformat/ip.c | 165 +++ libavformat/ip.h | 74 + 2 files changed, 239 insertions(+) create mode 100644 libavformat/ip.c create mode 100644 libavformat/ip.h [...] +/** + * Parses the address[,address] source list in buf and adds it to the filters + * in the IPSourceFilters structure. + * @param buf is the source list, which is not changed, but must be writable + * @return 0 on success, < 0 AVERROR code on error. + */ +int ff_ip_parse_sources(void *log_ctx, char *buf, IPSourceFilters *filters); + +/** + * Parses the address[,address] source block list in buf and adds it to the + * filters in the IPSourceFilters structure. + * @param buf is the source list, which is not changed, but must be writable if its not changed, why does it need to be writable ? Becasue the during the parsing the ',' is replaced with '\0' temporarily. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v4 30/38] vaapi_encode_h264: Enable multiple-slice support
On 19/09/18 02:33, myp...@gmail.com wrote:> > VA-API encoder can support multiple-frame reference too. That's loosely the intent, though it probably needs more information about similarities between frames for the feature to be of non-placebo use. In terms of the common implementation it should be possible to make an alternative pick_next() function which creates the set of references in a different way and have it work for all codecs (or at least H.264/5, VP9 and in future AV1; MPEG-2 and VP8 have constraints making them less general), though the codec-specific parts do still contain some assumptions about structure which would need to be ironed out for that to actually work. I think the information to make it useful could either come from somewhere external (e.g. a filter doing some sort of frame-similarity test and passing that information on), or it could be internal by running the encoder itself multiple times in different configurations and looking at the resulting output. Any thoughts you have on how this should work are welcome. On 19/09/18 04:20, myp...@gmail.com wrote: > On Wed, Sep 19, 2018 at 6:35 AM Mark Thompson wrote: >> >> --- >> libavcodec/vaapi_encode_h264.c | 13 +++-- >> 1 file changed, 7 insertions(+), 6 deletions(-) >> >> ... > Missing “slices” option in doc/encoder VA-API part, I think. other part LGTM Yep, added in new version. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file
On 9/23/2018 7:04 PM, Marton Balint wrote: > > > On Sun, 23 Sep 2018, Michael Niedermayer wrote: > >> On Sat, Sep 22, 2018 at 11:53:22PM +0200, Marton Balint wrote: >>> These are based on the very similar UDP and RTP protocol functions. >>> >>> Signed-off-by: Marton Balint >>> --- >>> libavformat/ip.c | 165 >>> +++ >>> libavformat/ip.h | 74 + >>> 2 files changed, 239 insertions(+) >>> create mode 100644 libavformat/ip.c >>> create mode 100644 libavformat/ip.h >> [...] >>> +/** >>> + * Parses the address[,address] source list in buf and adds it to >>> the filters >>> + * in the IPSourceFilters structure. >>> + * @param buf is the source list, which is not changed, but must be >>> writable >>> + * @return 0 on success, < 0 AVERROR code on error. >>> + */ >>> +int ff_ip_parse_sources(void *log_ctx, char *buf, IPSourceFilters >>> *filters); >>> + >>> +/** >>> + * Parses the address[,address] source block list in buf and adds it >>> to the >>> + * filters in the IPSourceFilters structure. >>> + * @param buf is the source list, which is not changed, but must be >>> writable >> >> if its not changed, why does it need to be writable ? > > Becasue the during the parsing the ',' is replaced with '\0' temporarily. Why not use av_get_token() or similar instead, to split it into separate strings? That way the buffer passed to the function can be const. > > Regards, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 2/3] lavc: Add coded bitstream read/write support for AV1
On 18/09/18 01:25, James Almer wrote: > On 9/17/2018 8:47 PM, Mark Thompson wrote: >> --- >> On 10/09/18 20:14, Michael Niedermayer wrote: >>> breaks build on mips: >>> CC libavcodec/av1_metadata_bsf.o >>> In file included from src/libavcodec/av1_metadata_bsf.c:25: >>> src/libavcodec/cbs_av1.h:364: warning: declaration does not declare anything >>> src/libavcodec/cbs_av1.h:380: warning: declaration does not declare anything >>> ... lots of errors because of anonymous unions ... >> >> Fixed by giving these unions redundant names. Anonymous unions would be >> nice, but they're probably a little too much trouble still for old compilers. > > I think GCC 4.8, used in CentOS, had trouble with those as well. But at > some point we should probably just set the minimum version to something > like GCC 4.9 (First version with C11 atomics). It would probably > simplify a lot of code beyond just anonymous unions. Or worse - RedHat/CentOS 6 is still supported by them, with GCC 4.4. While I do think it's sensible that these old versions still work where reasonable, I agree that it might be worth reassessing what is actually useful to support in the not-too-distant future. Moving to C11 in general isn't possible because Microsoft, but I think there are very few people who would be inconvenienced by the version requirement being bumped on the GCC/Clang side of things. >> ... > > Looks good now. Thanks! Great. Does anyone else have any comments? I'll push this in two days if there isn't anything further. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2 1/3] libaomenc: Add support for tiles
On 19/09/18 00:15, James Almer wrote: > On 9/18/2018 7:55 PM, Mark Thompson wrote: >> On 18/09/18 01:12, James Almer wrote: >>> On 9/17/2018 8:47 PM, Mark Thompson wrote: Adds an option to specify the number of tile rows and columns, then uses equal-sized tiles to fill the frame. --- libavcodec/libaomenc.c | 54 ++ 1 file changed, 54 insertions(+) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 6a79d9b873..3ccff0e0fb 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c ... @@ -742,6 +795,7 @@ static const AVOption options[] = { { "static-thresh","A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, { "drop-threshold", "Frame drop threshold", offsetof(AOMContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE }, { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE}, +{ "tiles","Tile rows x columns", OFFSET(tile_cols), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, VE }, >>> >>> Using separate tile-columns and tile-rows AV_OPT_TYPE_INT options would >>> be more consistent with the libvpx wrapper, which already has them >>> called like that and also shares a lot of other option names with the >>> libaom. >> >> The options on libvpx-vp9 are actually log2 of the value, so "-tile-rows 3 >> -tile-columns 2" gives you 8x4 tiles. (VP9 requires that the number of >> tiles in each dimension is a power of two, while AV1 lets you set arbitrary >> sizes.) >> >> I don't really mind how this works - I just thought the IMAGE_SIZE method >> looked nicer. What do you prefer? > > I usually prefer consistency in options for similar modules, but the > equivalent of the VP9 options would be to set the AV1E_SET_TILE_* codec > control IDs instead of what you're doing here, so your IMAGE_SIZE method > is fine. > > There's for that matter a conflicting patch called "lavc/libaomenc: Add > -tile-columns/-tile-rows" by Kagami Hiiragi that sets the aforementioned > codec control IDs with the same option names as the VP9 ones. Maybe both > patches can be applied, and have the encoder abort if they are used at > the same time? Otherwise apply yours alone since it allows arbitrary sizes. I think having both would make sense - the two different options are reflecting the different values of uniform_tile_spacing_flag. The explicit sizing can get the same result with the flag off as it being on, but will require more bits in every frame header to do so. On matching behaviour with libvpx, I don't think tile_cols/rows_log2 in VP9 and AV1 (with uniform_tile_spacing_flag = 1) actually do have the same effect - VP9 ensures that you get exactly 2^tile_cols_log2 tile columns, while for AV1 it's an upper bound and depends on the width. For example, given a width of 576 (as 9 64x64 superblocks) and tile_cols_log2 = 2, VP9 looks like it gives you { 2, 2, 2, 3 } while AV1 will give you { 3, 3, 3 } as the tile column widths. That probably wants to be mentioned in the documentation, and maybe merits the options not matching precisely. So, I'll look into supporting both cases in some consistent way. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file
On Sun, 23 Sep 2018, James Almer wrote: On 9/23/2018 7:04 PM, Marton Balint wrote: On Sun, 23 Sep 2018, Michael Niedermayer wrote: On Sat, Sep 22, 2018 at 11:53:22PM +0200, Marton Balint wrote: These are based on the very similar UDP and RTP protocol functions. Signed-off-by: Marton Balint --- libavformat/ip.c | 165 +++ libavformat/ip.h | 74 + 2 files changed, 239 insertions(+) create mode 100644 libavformat/ip.c create mode 100644 libavformat/ip.h [...] +/** + * Parses the address[,address] source list in buf and adds it to the filters + * in the IPSourceFilters structure. + * @param buf is the source list, which is not changed, but must be writable + * @return 0 on success, < 0 AVERROR code on error. + */ +int ff_ip_parse_sources(void *log_ctx, char *buf, IPSourceFilters *filters); + +/** + * Parses the address[,address] source block list in buf and adds it to the + * filters in the IPSourceFilters structure. + * @param buf is the source list, which is not changed, but must be writable if its not changed, why does it need to be writable ? Becasue the during the parsing the ',' is replaced with '\0' temporarily. Why not use av_get_token() or similar instead, to split it into separate strings? That way the buffer passed to the function can be const. That would cause some unnecesary mallocs/frees because we don't store the parsed address strings. Also this patch is mostly factorization, I tried to keep functional changes to the mimnium... Can be changed if any of you still prefer that. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file
On Mon, Sep 24, 2018 at 12:04:12AM +0200, Marton Balint wrote: > > > On Sun, 23 Sep 2018, Michael Niedermayer wrote: > > >On Sat, Sep 22, 2018 at 11:53:22PM +0200, Marton Balint wrote: > >>These are based on the very similar UDP and RTP protocol functions. > >> > >>Signed-off-by: Marton Balint > >>--- > >> libavformat/ip.c | 165 > >> +++ > >> libavformat/ip.h | 74 + > >> 2 files changed, 239 insertions(+) > >> create mode 100644 libavformat/ip.c > >> create mode 100644 libavformat/ip.h > >[...] > >>+/** > >>+ * Parses the address[,address] source list in buf and adds it to the > >>filters > >>+ * in the IPSourceFilters structure. > >>+ * @param buf is the source list, which is not changed, but must be > >>writable > >>+ * @return 0 on success, < 0 AVERROR code on error. > >>+ */ > >>+int ff_ip_parse_sources(void *log_ctx, char *buf, IPSourceFilters > >>*filters); > >>+ > >>+/** > >>+ * Parses the address[,address] source block list in buf and adds it to the > >>+ * filters in the IPSourceFilters structure. > >>+ * @param buf is the source list, which is not changed, but must be > >>writable > > > >if its not changed, why does it need to be writable ? > > Becasue the during the parsing the ',' is replaced with '\0' temporarily. this implies that the buffer cannot be shared with another thread. (which while unlikely could if its done result in very hard to reproduce bugs) This should be at least documented more clearly but i think it would be best to avoid these temporary writes as they are unexpected. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Freedom in capitalist society always remains about the same as it was in ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/cbs: Add JPEG support
2018-09-23 17:47 GMT+02:00, Mark Thompson : > +JPEG_MARKER_SOF0= 0xc0, > +JPEG_MARKER_SOF1= 0xc1, > +JPEG_MARKER_SOF2= 0xc2, > +JPEG_MARKER_SOF3= 0xc3, > + > +JPEG_MARKER_DHT = 0xc4, > +JPEG_MARKER_SOI = 0xd8, > +JPEG_MARKER_EOI = 0xd9, > +JPEG_MARKER_SOS = 0xda, > +JPEG_MARKER_DQT = 0xdb, > + > +JPEG_MARKER_APPN= 0xe0, > +JPEG_MARKER_JPGN= 0xf0, > +JPEG_MARKER_COM = 0xfe, Can't you include mjpeg.h here? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec: add an AV1 parser
Simple parser to set keyframes, frame type, structure, width, height, and pixel format, plus stream profile and level. Signed-off-by: James Almer --- Missing Changelog entry and version bump. This depends on "[PATCH v2 2/3] lavc: Add coded bitstream read/write support for AV1" which should be committed in the coming days. The AVCodecParser.split() implementation, added for the sake of completeness, is very naive and much like the h264 and hevc ones can result in useless OBUs being "extracted", but since it's no longer used by libavformat to fill global headers when reading raw containers it shouldn't really matter. It's pretty much used only by the remove_extradata bsf at this point. configure | 1 + libavcodec/Makefile | 1 + libavcodec/av1_parser.c | 218 libavcodec/parsers.c| 1 + 4 files changed, 221 insertions(+) create mode 100644 libavcodec/av1_parser.c diff --git a/configure b/configure index ca8b599b63..b46c86ec95 100755 --- a/configure +++ b/configure @@ -3020,6 +3020,7 @@ wmv3_crystalhd_decoder_select="crystalhd" # parsers aac_parser_select="adts_header" +av1_parser_select="cbs_av1" h264_parser_select="golomb h264dsp h264parse" hevc_parser_select="hevcparse" mpegaudio_parser_select="mpegaudioheader" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b2c6995f9a..dc28892e64 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1006,6 +1006,7 @@ OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \ mpeg4audio.o OBJS-$(CONFIG_AC3_PARSER) += ac3tab.o aac_ac3_parser.o OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o +OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c new file mode 100644 index 00..b2e19e2119 --- /dev/null +++ b/libavcodec/av1_parser.c @@ -0,0 +1,218 @@ +/* + * AV1 parser + * + * Copyright (C) 2018 James Almer + * + * 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 "av1_parse.h" +#include "cbs.h" +#include "cbs_av1.h" +#include "parser.h" + +typedef struct AV1ParseContext { +CodedBitstreamContext *cbc; +CodedBitstreamFragment temporal_unit; +int parsed_extradata; +} AV1ParseContext; + +static int av1_parser_parse(AVCodecParserContext *ctx, +AVCodecContext *avctx, +const uint8_t **out_data, int *out_size, +const uint8_t *data, int size) +{ +AV1ParseContext *s = ctx->priv_data; +CodedBitstreamFragment *td = &s->temporal_unit; +CodedBitstreamAV1Context *av1 = s->cbc->priv_data; +int ret; + +*out_data = data; +*out_size = size; + +ctx->key_frame = -1; +ctx->pict_type = AV_PICTURE_TYPE_NONE; +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; + +if (avctx->extradata_size && !s->parsed_extradata) { +ret = ff_cbs_read(s->cbc, td, avctx->extradata, avctx->extradata_size); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Failed to parse extradata.\n"); +return size; +} + +s->parsed_extradata = 1; + +ff_cbs_fragment_uninit(s->cbc, td); +} + +ret = ff_cbs_read(s->cbc, td, data, size); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Failed to parse temporal unit.\n"); +return size; +} + +if (!av1->sequence_header) { +av_log(avctx, AV_LOG_ERROR, "No sequence header available\n"); +goto end; +} + +for (int i = 0; i < td->nb_units; i++) { +CodedBitstreamUnit *unit = &td->units[i]; +AV1RawOBU *obu = unit->content; +AV1RawSequenceHeader *seq = av1->sequence_header; +AV1RawFrameHeader *frame; +int frame_type, bitdepth, subsampling; + +if (unit->type == AV1_OBU_FRAME) +frame = &obu->obu.frame.header; +else if (unit->type == AV1_OBU_FRAME_HEADER) +frame = &obu->obu.frame_header; +else +
[FFmpeg-devel] [PATCH] avformat/ivfenc: fix writing codec tag
The value in AVCodecParameters->codec_tag may not be correct for IVF, as it's the case when remuxing AV1 streams from mp4, so ignore it and write the correct value based on codec ID instead. Signed-off-by: James Almer --- libavformat/ivfenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c index af803d59ee..66441a2a43 100644 --- a/libavformat/ivfenc.c +++ b/libavformat/ivfenc.c @@ -46,7 +46,7 @@ static int ivf_write_header(AVFormatContext *s) avio_write(pb, "DKIF", 4); avio_wl16(pb, 0); // version avio_wl16(pb, 32); // header length -avio_wl32(pb, par->codec_tag ? par->codec_tag : +avio_wl32(pb, par->codec_id == AV_CODEC_ID_VP9 ? AV_RL32("VP90") : par->codec_id == AV_CODEC_ID_VP8 ? AV_RL32("VP80") : AV_RL32("AV01")); avio_wl16(pb, par->width); -- 2.19.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter/sr: process and output message when load_model is NULL
fix ticket: 7455 Signed-off-by: Steven Liu --- libavfilter/dnn_interface.c | 4 libavfilter/vf_sr.c | 7 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavfilter/dnn_interface.c b/libavfilter/dnn_interface.c index 78d7c5cf22..792c280c53 100644 --- a/libavfilter/dnn_interface.c +++ b/libavfilter/dnn_interface.c @@ -52,6 +52,10 @@ DNNModule *ff_get_dnn_module(DNNBackendType backend_type) av_freep(&dnn_module); return NULL; #endif +default: +av_log(NULL, AV_LOG_ERROR, "Module backend_type is not native or tensorflow\n"); +av_freep(&dnn_module); +return NULL; } return dnn_module; diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c index 077ccc799c..6423d2ea11 100644 --- a/libavfilter/vf_sr.c +++ b/libavfilter/vf_sr.c @@ -75,7 +75,12 @@ static av_cold int init(AVFilterContext *context) return AVERROR(EIO); } else{ -sr_context->model = (sr_context->dnn_module->load_model)(sr_context->model_filename); +if (!sr_context->dnn_module->load_model) { +av_log(context, AV_LOG_ERROR, "load_model for network was not specified\n"); +return AVERROR(EIO); +} else { +sr_context->model = (sr_context->dnn_module->load_model)(sr_context->model_filename); +} } if (!sr_context->model){ av_log(context, AV_LOG_ERROR, "could not load DNN model\n"); -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add an AV1 parser
On 9/23/2018 9:12 PM, James Almer wrote: > +subsampling = seq->color_config.subsampling_x << 1 & > seq->color_config.subsampling_y; Changed the logical and into a logical or locally. > +bitdepth= 8 + seq->color_config.high_bitdepth * 2 + > seq->color_config.twelve_bit * 2; > +switch (bitdepth) { > +case 8: > +if (subsampling == 3) ctx->format = > seq->color_config.mono_chrome ? AV_PIX_FMT_GRAY8 : > + > AV_PIX_FMT_YUV420P; > +else if (subsampling == 2) ctx->format = AV_PIX_FMT_YUV422P; > +else ctx->format = AV_PIX_FMT_YUV444P; > +break; > +case 10: > +if (subsampling == 3) ctx->format = > seq->color_config.mono_chrome ? AV_PIX_FMT_GRAY10 : > + > AV_PIX_FMT_YUV420P10; > +else if (subsampling == 2) ctx->format = AV_PIX_FMT_YUV422P10; > +else ctx->format = AV_PIX_FMT_YUV444P10; > +break; > +case 12: > +if (subsampling == 3) ctx->format = > seq->color_config.mono_chrome ? AV_PIX_FMT_GRAY12 : > + > AV_PIX_FMT_YUV420P12; > +else if (subsampling == 2) ctx->format = AV_PIX_FMT_YUV422P12; > +else ctx->format = AV_PIX_FMT_YUV444P12; > +break; > +} ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCHv2 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file
These are based on the very similar UDP and RTP protocol functions. Signed-off-by: Marton Balint --- libavformat/ip.c | 159 +++ libavformat/ip.h | 72 + 2 files changed, 231 insertions(+) create mode 100644 libavformat/ip.c create mode 100644 libavformat/ip.h diff --git a/libavformat/ip.c b/libavformat/ip.c new file mode 100644 index 00..70c5529b72 --- /dev/null +++ b/libavformat/ip.c @@ -0,0 +1,159 @@ +/* + * IP common code + * + * 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 "ip.h" +#include "libavutil/avstring.h" + +static int compare_addr(const struct sockaddr_storage *a, +const struct sockaddr_storage *b) +{ +if (a->ss_family != b->ss_family) +return 1; +if (a->ss_family == AF_INET) { +return (((const struct sockaddr_in *)a)->sin_addr.s_addr != +((const struct sockaddr_in *)b)->sin_addr.s_addr); +} + +#if HAVE_STRUCT_SOCKADDR_IN6 +if (a->ss_family == AF_INET6) { +const uint8_t *s6_addr_a = ((const struct sockaddr_in6 *)a)->sin6_addr.s6_addr; +const uint8_t *s6_addr_b = ((const struct sockaddr_in6 *)b)->sin6_addr.s6_addr; +return memcmp(s6_addr_a, s6_addr_b, 16); +} +#endif +return 1; +} + +int ff_ip_check_source_lists(struct sockaddr_storage *source_addr_ptr, IPSourceFilters *s) +{ +int i; +if (s->nb_exclude_addrs) { +for (i = 0; i < s->nb_exclude_addrs; i++) { +if (!compare_addr(source_addr_ptr, &s->exclude_addrs[i])) +return 1; +} +} +if (s->nb_include_addrs) { +for (i = 0; i < s->nb_include_addrs; i++) { +if (!compare_addr(source_addr_ptr, &s->include_addrs[i])) +return 0; +} +return 1; +} +return 0; +} + +struct addrinfo *ff_ip_resolve_host(void *log_ctx, +const char *hostname, int port, +int type, int family, int flags) +{ +struct addrinfo hints = { 0 }, *res = 0; +int error; +char sport[16]; +const char *node = 0, *service = "0"; + +if (port > 0) { +snprintf(sport, sizeof(sport), "%d", port); +service = sport; +} +if ((hostname) && (hostname[0] != '\0') && (hostname[0] != '?')) { +node = hostname; +} +hints.ai_socktype = type; +hints.ai_family = family; +hints.ai_flags= flags; +if ((error = getaddrinfo(node, service, &hints, &res))) { +res = NULL; +av_log(log_ctx, AV_LOG_ERROR, "getaddrinfo(%s, %s): %s\n", + node ? node : "unknown", + service, + gai_strerror(error)); +} + +return res; +} + + +static int ip_parse_addr_list(void *log_ctx, const char *buf, + struct sockaddr_storage **address_list_ptr, + int *address_list_size_ptr) +{ +struct addrinfo *ai = NULL; + +/* Resolve all of the IPs */ + +while (buf && buf[0]) { +char* host = av_get_token(&buf, ","); +if (!host) +return AVERROR(ENOMEM); + +ai = ff_ip_resolve_host(log_ctx, host, 0, SOCK_DGRAM, AF_UNSPEC, 0); +av_freep(&host); + +if (ai) { +struct sockaddr_storage source_addr = {0}; +memcpy(&source_addr, ai->ai_addr, ai->ai_addrlen); +freeaddrinfo(ai); +av_dynarray2_add((void **)address_list_ptr, address_list_size_ptr, sizeof(source_addr), (uint8_t *)&source_addr); +if (!*address_list_ptr) +return AVERROR(ENOMEM); +} else { +return AVERROR(EINVAL); +} + +if (*buf) +buf++; +} + +return 0; +} + +static int ip_parse_sources_and_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters, int parse_include_list) +{ +int ret; +if (parse_include_list) +ret = ip_parse_addr_list(log_ctx, buf, &filters->include_addrs, &filters->nb_include_addrs); +else +ret = ip_parse_addr_list(log_ctx, buf, &filters->exclude_addrs, &filters->nb_exclude_addrs); + +if (ret >= 0 && filters->nb_include_addrs && filters->nb_exclude_