[FFmpeg-devel] [PATCH] lavc/qsv: Standardize some usages of ff_qsv_print_error
ff_qsv_print_error would output the ":" and "\n" internally in the function. Signed-off-by: Linjie Fu --- libavcodec/qsv.c| 2 +- libavcodec/qsvdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index b00e427435..ec87ed7a3f 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -401,7 +401,7 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) ret = MFXVideoCORE_SetHandle(qs->session, (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)hwctx->display); if (ret < 0) { -return ff_qsv_print_error(avctx, ret, "Error during set display handle\n"); +return ff_qsv_print_error(avctx, ret, "Error during set display handle"); } } diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index ae5023989c..e698cb6c9f 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -468,7 +468,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, ret != MFX_ERR_MORE_SURFACE) { av_freep(&sync); return ff_qsv_print_error(avctx, ret, - "Error during QSV decoding."); + "Error during QSV decoding"); } /* make sure we do not enter an infinite loop if the SDK -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavc/vaapi_decode: Set surfaces reference pool size according to SPS for H.264/HEVC
> -Original Message- > From: Fu, Linjie > Sent: Wednesday, November 6, 2019 12:54 > To: ffmpeg-devel@ffmpeg.org > Cc: Fu, Linjie > Subject: [PATCH] lavc/vaapi_decode: Set surfaces reference pool size > according to SPS for H.264/HEVC > > Set surfaces pool used for storing reference frames dynamically > according to SPS.(reference framecount, reordered frame number, etc) > > Compared to a fixed pool size for H.264 and HEVC, the usage of > GPU memory could be improved. > > CMD: > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 > -i bbb_sunflower_1080p_30fps_normal.mp4 -f null - > Source: > https://download.blender.org/demo/movies/BBB/ > > GEM Object memory usage: > watch cat /sys/kernel/debug/dri/0/i915_gem_objects > Before: > ~112M > After: > ~80M > > Signed-off-by: Linjie Fu > --- > libavcodec/vaapi_decode.c | 39 ++- > libavcodec/vaapi_decode.h | 3 +++ > libavcodec/vaapi_h264.c | 11 ++- > libavcodec/vaapi_hevc.c | 11 ++- > libavcodec/vaapi_vp8.c| 8 +++- > libavcodec/vaapi_vp9.c| 8 +++- > 6 files changed, 55 insertions(+), 25 deletions(-) > > diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c > index 69512e1d45..5fc9767802 100644 > --- a/libavcodec/vaapi_decode.c > +++ b/libavcodec/vaapi_decode.c > @@ -408,7 +408,8 @@ static const struct { > static int vaapi_decode_make_config(AVCodecContext *avctx, > AVBufferRef *device_ref, > VAConfigID *va_config, > -AVBufferRef *frames_ref) > +AVBufferRef *frames_ref, > +int dpb_size) > { > AVVAAPIHWConfig *hwconfig= NULL; > AVHWFramesConstraints *constraints = NULL; > @@ -549,22 +550,8 @@ static int > vaapi_decode_make_config(AVCodecContext *avctx, > if (err < 0) > goto fail; > > -frames->initial_pool_size = 1; > -// Add per-codec number of surfaces used for storing reference > frames. > -switch (avctx->codec_id) { > -case AV_CODEC_ID_H264: > -case AV_CODEC_ID_HEVC: > -frames->initial_pool_size += 16; > -break; > -case AV_CODEC_ID_VP9: > -frames->initial_pool_size += 8; > -break; > -case AV_CODEC_ID_VP8: > -frames->initial_pool_size += 3; > -break; > -default: > -frames->initial_pool_size += 2; > -} > +if (dpb_size > 0) > +frames->initial_pool_size = dpb_size + 1; > } > > av_hwframe_constraints_free(&constraints); > @@ -583,8 +570,9 @@ fail: > return err; > } > > -int ff_vaapi_common_frame_params(AVCodecContext *avctx, > - AVBufferRef *hw_frames_ctx) > +int ff_vaapi_frame_params_with_dpb_size(AVCodecContext *avctx, > +AVBufferRef *hw_frames_ctx, > +int dpb_size) > { > AVHWFramesContext *hw_frames = (AVHWFramesContext > *)hw_frames_ctx->data; > AVHWDeviceContext *device_ctx = hw_frames->device_ctx; > @@ -597,7 +585,7 @@ int > ff_vaapi_common_frame_params(AVCodecContext *avctx, > hwctx = device_ctx->hwctx; > > err = vaapi_decode_make_config(avctx, hw_frames->device_ref, > &va_config, > - hw_frames_ctx); > + hw_frames_ctx, dpb_size); > if (err) > return err; > > @@ -607,6 +595,13 @@ int > ff_vaapi_common_frame_params(AVCodecContext *avctx, > return 0; > } > > +int ff_vaapi_common_frame_params(AVCodecContext *avctx, > + AVBufferRef *hw_frames_ctx) > +{ > +// Set common dpb_size for vc1/mjpeg/mpeg2/mpeg4. > +return ff_vaapi_frame_params_with_dpb_size(avctx, hw_frames_ctx, 2); > +} > + > int ff_vaapi_decode_init(AVCodecContext *avctx) > { > VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data; > @@ -666,7 +661,9 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) > ctx->hwctx = ctx->device->hwctx; > > err = vaapi_decode_make_config(avctx, ctx->frames->device_ref, > - &ctx->va_config, avctx->hw_frames_ctx); > + &ctx->va_config, avctx->hw_frames_ctx, > + 0); > + > if (err) > goto fail; > > diff --git a/libavcodec/vaapi_decode.h b/libavcodec/vaapi_decode.h > index 6b415dd1d3..c3e74bf9c7 100644 > --- a/libavcodec/vaapi_decode.h > +++ b/libavcodec/vaapi_decode.h > @@ -98,6 +98,9 @@ int ff_vaapi_decode_cancel(AVCodecContext *avctx, > int ff_vaapi_decode_init(AVCodecContext *avctx); > int ff_vaapi_decode_uninit(AVCodecContext *avctx); > > +int ff_vaapi_frame_params_with_dpb_size(AVCodecContext *avctx, > +
Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: Async the encoding and output procedure of encoder
> -Original Message- > From: Fu, Linjie > Sent: Friday, November 8, 2019 00:32 > To: ffmpeg-devel@ffmpeg.org > Cc: Fu, Linjie > Subject: [PATCH] lavc/vaapi_encode: Async the encoding and output > procedure of encoder > > Currently, vaapi encodes a pic if all its references are ready, > and then outputs it immediately by calling vaapi_encode_output. > > However, while working on output procedure, hardware is be able to > cope with encoding tasks in the meantime to have the better performance. > > So a more efficient way is to send all the pics with available refs to > hardware to allow encoding while output. > > It's what vaapi originally did before the regression, and the performance > could be improved for ~20%. > > CMD: > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 > -hwaccel_output_format vaapi -i bbb_sunflower_1080p_30fps_normal.mp4 > -c:v h264_vaapi -f h264 -y /dev/null > > Source: > https://download.blender.org/demo/movies/BBB/ > > Before: > ~164 fps > After: > ~198 fps > > Fix #7706. > > Signed-off-by: Linjie Fu > --- > libavcodec/vaapi_encode.c | 27 +++ > 1 file changed, 19 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c > index 3be9159d37..aceb268315 100644 > --- a/libavcodec/vaapi_encode.c > +++ b/libavcodec/vaapi_encode.c > @@ -1109,17 +1109,28 @@ int > ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt) > return AVERROR(EAGAIN); > } > > +pick_next: > pic = NULL; > err = vaapi_encode_pick_next(avctx, &pic); > -if (err < 0) > -return err; > -av_assert0(pic); > +if (!err) { > +av_assert0(pic); > > -pic->encode_order = ctx->encode_order++; > +pic->encode_order = ctx->encode_order++; > > -err = vaapi_encode_issue(avctx, pic); > -if (err < 0) { > -av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err); > +err = vaapi_encode_issue(avctx, pic); > +if (err < 0) { > +av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err); > +return err; > +} > +goto pick_next; > +} else if (err == AVERROR(EAGAIN)) { > +for (pic = ctx->pic_start; pic; pic = pic->next) > +if (pic->encode_issued && !pic->encode_complete && > +pic->encode_order == ctx->output_order) > +break; > +if (!pic) > +return err; > +} else { > return err; > } > > @@ -1143,7 +1154,7 @@ int > ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt) > av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64" > dts %"PRId64".\n", > pkt->pts, pkt->dts); > > -ctx->output_order = pic->encode_order; > +ctx->output_order++; > vaapi_encode_clear_old(avctx); > > return 0; Ping. - linjie ___ 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] avcodec/dvdec: Don't use restrict directly to fix build on MSVC
I can confirm this patch fixes the compile problem on MSVC. See: https://ci.appveyor.com/project/mcmtroffaes/ffmpeg-msvc-build/build/job/get5kbjlyw6w1vi5 https://github.com/mcmtroffaes/ffmpeg-msvc-build/commit/d1cc29f4c56937ec75b297bc6feaf0fd8989a549 Kind regards, Matthias On Sun, Nov 10, 2019 at 1:47 AM Andreas Rheinhardt wrote: > > 004ebd4b added a function with a parameter that was declared as restrict > and not av_restrict. This is not supported by MSVC as several FATE-boxes > that now fail to build show. So use av_restrict. > > Signed-off-by: Andreas Rheinhardt > --- > Here is one of many logs of a failing build with MSVC: > http://fate.ffmpeg.org/log.cgi?slot=x86_64-msvc15-windows-native&log=compile&time=20191110013536 > > I don't have an MSVC setup and can therefore only attest that this patch > doesn't affect either GCC or Clang (as expected). > > libavcodec/dvdec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c > index cfa0fb9905..578d7f505f 100644 > --- a/libavcodec/dvdec.c > +++ b/libavcodec/dvdec.c > @@ -269,7 +269,7 @@ static inline void bit_copy(PutBitContext *pb, > GetBitContext *gb) > put_bits(pb, bits_left, get_bits(gb, bits_left)); > } > > -static av_always_inline void put_block_8x4(int16_t *block, uint8_t *restrict > p, int stride) > +static av_always_inline void put_block_8x4(int16_t *block, uint8_t > *av_restrict p, int stride) > { > int i, j; > const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; > -- > 2.20.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 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 V4] avfilter/vf_bilateral: process command to set the parameter at runtime
ping, at the beginning of the new week:) leozhang 于2019年11月3日周日 下午6:50写道: > > Reviewed-by: Paul B Mahol > Reviewed-by: Jun Zhao > Signed-off-by: leozhang > --- > libavfilter/vf_bilateral.c | 39 ++- > 1 file changed, 34 insertions(+), 5 deletions(-) > > diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c > index 3c9d800..ba3631c 100644 > --- a/libavfilter/vf_bilateral.c > +++ b/libavfilter/vf_bilateral.c > @@ -29,6 +29,8 @@ > #include "internal.h" > #include "video.h" > > +#include > + > typedef struct BilateralContext { > const AVClass *class; > > @@ -54,7 +56,7 @@ typedef struct BilateralContext { > } BilateralContext; > > #define OFFSET(x) offsetof(BilateralContext, x) > -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > +#define FLAGS > AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM > > static const AVOption bilateral_options[] = { > { "sigmaS", "set spatial sigma",OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, > {.dbl=0.1}, 0.0, 10, FLAGS }, > @@ -91,19 +93,27 @@ static int query_formats(AVFilterContext *ctx) > return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); > } > > -static int config_input(AVFilterLink *inlink) > +static int init_lut(BilateralContext *s) > { > -BilateralContext *s = inlink->dst->priv; > -const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > float inv_sigma_range; > > -s->depth = desc->comp[0].depth; > inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1)); > > //compute a lookup table > for (int i = 0; i < (1 << s->depth); i++) > s->range_table[i] = expf(-i * inv_sigma_range); > > +return 0; > +} > + > +static int config_input(AVFilterLink *inlink) > +{ > +BilateralContext *s = inlink->dst->priv; > +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > + > +s->depth = desc->comp[0].depth; > +init_lut(s); > + > s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, > desc->log2_chroma_w); > s->planewidth[0] = s->planewidth[3] = inlink->w; > s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, > desc->log2_chroma_h); > @@ -325,6 +335,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *in) > return ff_filter_frame(outlink, out); > } > > +static int process_command(AVFilterContext *ctx, const char *cmd, const char > *args, > + char *res, int res_len, int flags) > +{ > +BilateralContext *s = ctx->priv; > +int ret; > +float old_sigmaR = s->sigmaR; > + > +if ((ret = ff_filter_process_command(ctx, cmd, args, res, res_len, > flags)) < 0) { > +return ret; > +} > + > +if (fabs(old_sigmaR - s->sigmaR) > FLT_EPSILON && (ret = init_lut(s)) < > 0) { > +s->sigmaR = old_sigmaR; > +} > + > +return ret; > +} > + > static av_cold void uninit(AVFilterContext *ctx) > { > BilateralContext *s = ctx->priv; > @@ -367,4 +395,5 @@ AVFilter ff_vf_bilateral = { > .inputs= bilateral_inputs, > .outputs = bilateral_outputs, > .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, > +.process_command = process_command, > }; > -- > 1.8.3.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-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 0/5] AV1 Annex B demuxer
This includes a bitstream filter to merge Temporal Units split across different AVPackets, given that Annex B encapsulation splits OBUs at the Temporal Unit, Frame and OBU boundaries. Bitstream reconstruction is required to prevent propagating AVPackets with contents that could generate invalid files in other containers. TODO: Changelog entries and lavc/lavf version bump. James Almer (5): avcodec/cbs_av1: support one byte long OBUs when the size is not set in the bitstream avcodec: add an AV1 frame merge BSF avcodec/av1_parser: export bitstream timing info when available avcodec/libdav1d: export bitstream timing info when available avformat: add an AV1 Annex B demuxer configure| 2 + libavcodec/Makefile | 1 + libavcodec/av1_frame_merge_bsf.c | 153 + libavcodec/av1_parser.c | 3 + libavcodec/bitstream_filters.c | 1 + libavcodec/cbs_av1.c | 13 +- libavcodec/libdav1d.c| 7 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/obu.c| 276 +++ 10 files changed, 451 insertions(+), 7 deletions(-) create mode 100644 libavcodec/av1_frame_merge_bsf.c create mode 100644 libavformat/obu.c -- 2.23.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] avcodec/libdav1d: export bitstream timing info when available
Signed-off-by: James Almer --- libavcodec/libdav1d.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 98737cb162..cf4b178f1d 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -287,6 +287,13 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) else frame->reordered_opaque = AV_NOPTS_VALUE; +if (p->seq_hdr->num_units_in_tick && p->seq_hdr->time_scale) { +av_reduce(&c->framerate.den, &c->framerate.num, + p->seq_hdr->num_units_in_tick, p->seq_hdr->time_scale, INT_MAX); +if (p->seq_hdr->equal_picture_interval) +c->ticks_per_frame = p->seq_hdr->num_ticks_per_picture; +} + // match timestamps and packet size frame->pts = frame->best_effort_timestamp = p->m.timestamp; #if FF_API_PKT_PTS -- 2.23.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] avformat: add an AV1 Annex B demuxer
Signed-off-by: James Almer --- configure| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/obu.c| 276 +++ 4 files changed, 279 insertions(+) create mode 100644 libavformat/obu.c diff --git a/configure b/configure index 70f60997c1..a8dbba879d 100755 --- a/configure +++ b/configure @@ -3293,6 +3293,7 @@ mxf_d10_muxer_select="mxf_muxer" mxf_opatom_muxer_select="mxf_muxer" nut_muxer_select="riffenc" nuv_demuxer_select="riffdec" +obu_demuxer_select="av1_frame_merge_bsf" oga_muxer_select="ogg_muxer" ogg_demuxer_select="dirac_parse" ogv_muxer_select="ogg_muxer" diff --git a/libavformat/Makefile b/libavformat/Makefile index 8251f8f657..9057d0358a 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -350,6 +350,7 @@ OBJS-$(CONFIG_NULL_MUXER)+= nullenc.o OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o isom.o OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o +OBJS-$(CONFIG_OBU_DEMUXER) += obu.o OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ oggparsecelt.o \ oggparsedaala.o \ diff --git a/libavformat/allformats.c b/libavformat/allformats.c index f7fea32b45..152644e9f9 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -282,6 +282,7 @@ extern AVInputFormat ff_nut_demuxer; extern AVOutputFormat ff_nut_muxer; extern AVInputFormat ff_nuv_demuxer; extern AVOutputFormat ff_oga_muxer; +extern AVInputFormat ff_obu_demuxer; extern AVInputFormat ff_ogg_demuxer; extern AVOutputFormat ff_ogg_muxer; extern AVOutputFormat ff_ogv_muxer; diff --git a/libavformat/obu.c b/libavformat/obu.c new file mode 100644 index 00..55a9c7d55f --- /dev/null +++ b/libavformat/obu.c @@ -0,0 +1,276 @@ +/* + * AV1 Annex-B demuxer + * Copyright (c) 2019 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 "config.h" + +#include "libavutil/common.h" +#include "libavutil/opt.h" +#include "libavcodec/av1_parse.h" +#include "avformat.h" +#include "avio_internal.h" +#include "internal.h" + +typedef struct AnnexBContext { +const AVClass *class; +AVBSFContext *bsf; +uint32_t temporal_unit_size; +uint32_t frame_unit_size; +AVRational framerate; +} AnnexBContext; + +static int leb(AVIOContext *pb, uint32_t *len) { +int more, i = 0; +uint8_t byte; +*len = 0; +do { +unsigned bits; +byte = avio_r8(pb); +more = byte & 0x80; +bits = byte & 0x7f; +if (i <= 3 || (i == 4 && bits < (1 << 4))) +*len |= bits << (i * 7); +else if (bits) +return AVERROR_INVALIDDATA; +if (++i == 8 && more) +return AVERROR_INVALIDDATA; +if (pb->eof_reached || pb->error) +return pb->error ? pb->error : AVERROR(EIO); +} while (more); +return i; +} + +static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int *type) +{ +int start_pos, temporal_id, spatial_id; +int len; + +len = parse_obu_header(buf, size, obu_size, &start_pos, + type, &temporal_id, &spatial_id); +if (len < 0) +return len; + +return 0; +} + +static int annexb_probe(const AVProbeData *p) +{ +AVIOContext pb; +int64_t obu_size; +uint32_t temporal_unit_size, frame_unit_size, obu_unit_size; +int seq = 0, frame_header = 0; +int ret, type, cnt = 0; + +ffio_init_context(&pb, p->buf, p->buf_size, 0, + NULL, NULL, NULL, NULL); + +ret = leb(&pb, &temporal_unit_size); +if (ret < 0) +return 0; +cnt += ret; +ret = leb(&pb, &frame_unit_size); +if (ret < 0 || (frame_unit_size + ret) > temporal_unit_size) +return 0; +cnt += ret; +temporal_unit_size -= ret; +ret = leb(&pb, &obu_unit_size); +if (ret < 0 || (obu_unit_size + ret) >= frame_unit_size) +return 0; +cnt += ret; + +temporal_unit_size -= obu_unit_size + ret; +frame_unit_size -= obu_unit_size + ret; + +avio_skip(&pb, obu_unit_size); +if (pb.eof_rea
[FFmpeg-devel] [PATCH 3/5] avcodec/av1_parser: export bitstream timing info when available
Based on h264_parser code. Signed-off-by: James Almer --- libavcodec/av1_parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c index b916608d65..510cad987b 100644 --- a/libavcodec/av1_parser.c +++ b/libavcodec/av1_parser.c @@ -157,6 +157,9 @@ static int av1_parser_parse(AVCodecParserContext *ctx, av_assert2(ctx->format != AV_PIX_FMT_NONE); } +if (avctx->framerate.num) +avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1})); + end: ff_cbs_fragment_reset(s->cbc, td); -- 2.23.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 1/5] avcodec/cbs_av1: support one byte long OBUs when the size is not set in the bitstream
This was missed in 96717a42715fdcc2f93558206e24d6dfd26b8d58, and will be needed by the next commit, where packets with a single Temporal Delimiter OBU with no size need to be parsed. Signed-off-by: James Almer --- libavcodec/cbs_av1.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index c027933218..cca112ecf8 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -768,14 +768,13 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, if (err < 0) goto fail; -if (get_bits_left(&gbc) < 8) { -av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid OBU: fragment " - "too short (%"SIZE_SPECIFIER" bytes).\n", size); -err = AVERROR_INVALIDDATA; -goto fail; -} - if (header.obu_has_size_field) { +if (get_bits_left(&gbc) < 8) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid OBU: fragment " + "too short (%"SIZE_SPECIFIER" bytes).\n", size); +err = AVERROR_INVALIDDATA; +goto fail; +} err = cbs_av1_read_leb128(ctx, &gbc, "obu_size", &obu_size); if (err < 0) goto fail; -- 2.23.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/dvdec: Don't use restrict directly to fix build on MSVC
On Mon, Nov 11, 2019 at 11:02:25AM +, Matthias Troffaes wrote: > I can confirm this patch fixes the compile problem on MSVC. See: > > https://ci.appveyor.com/project/mcmtroffaes/ffmpeg-msvc-build/build/job/get5kbjlyw6w1vi5 > https://github.com/mcmtroffaes/ffmpeg-msvc-build/commit/d1cc29f4c56937ec75b297bc6feaf0fd8989a549 will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1 1/3] tests/fate/filter-video: add test for colorlevels
On Wed, Oct 23, 2019 at 06:27:41PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > tests/fate/filter-video.mak | 6 +++ > tests/ref/fate/filter-colorlevels| 55 > tests/ref/fate/filter-colorlevels-16 | 55 > 3 files changed, 116 insertions(+) > create mode 100644 tests/ref/fate/filter-colorlevels > create mode 100644 tests/ref/fate/filter-colorlevels-16 Tested on x86-32/64 mingw32/64 arm/mips will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle 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".
[FFmpeg-devel] [PATCH 2/5] avcodec: add an AV1 frame merge bitstream filter
This BSF takes Temporal Units split across different AVPackets and merges them by looking for Temporal Delimiter OBUs. Signed-off-by: James Almer --- configure| 1 + libavcodec/Makefile | 1 + libavcodec/av1_frame_merge_bsf.c | 153 +++ libavcodec/bitstream_filters.c | 1 + 4 files changed, 156 insertions(+) create mode 100644 libavcodec/av1_frame_merge_bsf.c diff --git a/configure b/configure index 1de90e93fd..70f60997c1 100755 --- a/configure +++ b/configure @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp" # bitstream_filters aac_adtstoasc_bsf_select="adts_header" +av1_frame_merge_bsf_select="cbs_av1" av1_frame_split_bsf_select="cbs_av1" av1_metadata_bsf_select="cbs_av1" eac3_core_bsf_select="ac3_parser" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b990c6ba87..006a472a6d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o # bitstream filters OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o mpeg4audio.o OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o diff --git a/libavcodec/av1_frame_merge_bsf.c b/libavcodec/av1_frame_merge_bsf.c new file mode 100644 index 00..943cfcb426 --- /dev/null +++ b/libavcodec/av1_frame_merge_bsf.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2019 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 "avcodec.h" +#include "bsf.h" +#include "cbs.h" +#include "cbs_av1.h" + +typedef struct AV1FMergeContext { +CodedBitstreamContext *cbc; +CodedBitstreamFragment temporal_unit; +CodedBitstreamFragment frag; +} AV1FMergeContext; + +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *pkt) +{ +AV1FMergeContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = &ctx->frag, *tu = &ctx->temporal_unit; +int err, i; + +err = ff_bsf_get_packet_ref(bsf, pkt); +if (err < 0) { +if (err == AVERROR_EOF && tu->nb_units > 0) +goto eof; +return err; +} + +err = ff_cbs_read_packet(ctx->cbc, frag, pkt); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); +goto fail; +} + +if (frag->nb_units == 0) { +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n"); +err = AVERROR_INVALIDDATA; +goto fail; +} + +if (tu->nb_units == 0 && frag->units[0].type != AV1_OBU_TEMPORAL_DELIMITER) { +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n"); +err = AVERROR_INVALIDDATA; +goto fail; +} + +if (tu->nb_units > 0 && frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) { +eof: +err = ff_cbs_write_packet(ctx->cbc, pkt, tu); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); +goto fail; +} +ff_cbs_fragment_reset(ctx->cbc, tu); + +for (i = 0; i < frag->nb_units; i++) { +if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) { +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of a packet.\n"); +err = AVERROR_INVALIDDATA; +goto fail; +} +err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, frag->units[i].type, + frag->units[i].content, frag->units[i].content_ref); +if (err < 0) +goto fail; +} +ff_cbs_fragment_reset(ctx->cbc, frag); + +return err; +} + +for (i = 0; i < frag->nb_units; i++) { +if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) { +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of a packet.\n"); +err = AVERROR_INVALIDDATA; +goto fail; +} +err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, frag->units[i].type, +
[FFmpeg-devel] [PATCH] librav1e: Don't make users explicitly set -qp -1 to use bit rate mode
Signed-off-by: Derek Buitenhuis --- libavcodec/librav1e.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 5052cac896..11c1d09e36 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -329,6 +329,10 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx) } } +/* We can't easily represent this behavior with AVOptions, so do it here. */ +if (!avctx->bit_rate && ctx->quantizer < 0) +ctx->quantizer = 100; + if (avctx->bit_rate && ctx->quantizer < 0) { int max_quantizer = avctx->qmax >= 0 ? avctx->qmax : 255; @@ -533,7 +537,7 @@ retry: #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "qp", "use constant quantizer mode", OFFSET(quantizer), AV_OPT_TYPE_INT, { .i64 = 100 }, -1, 255, VE }, +{ "qp", "use constant quantizer mode (defaults to 100 if no bit rate is set)", OFFSET(quantizer), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, VE }, { "speed", "what speed preset to use", OFFSET(speed), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 10, VE }, { "tiles", "number of tiles encode with", OFFSET(tiles), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE }, { "tile-rows", "number of tiles rows to encode with", OFFSET(tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE }, -- 2.24.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5] avcodec: add an AV1 frame merge bitstream filter
James Almer: > This BSF takes Temporal Units split across different AVPackets and merges them > by looking for Temporal Delimiter OBUs. > > Signed-off-by: James Almer > --- > configure| 1 + > libavcodec/Makefile | 1 + > libavcodec/av1_frame_merge_bsf.c | 153 +++ > libavcodec/bitstream_filters.c | 1 + > 4 files changed, 156 insertions(+) > create mode 100644 libavcodec/av1_frame_merge_bsf.c > > diff --git a/configure b/configure > index 1de90e93fd..70f60997c1 100755 > --- a/configure > +++ b/configure > @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp" > > # bitstream_filters > aac_adtstoasc_bsf_select="adts_header" > +av1_frame_merge_bsf_select="cbs_av1" > av1_frame_split_bsf_select="cbs_av1" > av1_metadata_bsf_select="cbs_av1" > eac3_core_bsf_select="ac3_parser" > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index b990c6ba87..006a472a6d 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o > # bitstream filters > OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o mpeg4audio.o > OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o > +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o > OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o > OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o > OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o > diff --git a/libavcodec/av1_frame_merge_bsf.c > b/libavcodec/av1_frame_merge_bsf.c > new file mode 100644 > index 00..943cfcb426 > --- /dev/null > +++ b/libavcodec/av1_frame_merge_bsf.c > @@ -0,0 +1,153 @@ > +/* > + * Copyright (c) 2019 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 "avcodec.h" > +#include "bsf.h" > +#include "cbs.h" > +#include "cbs_av1.h" > + > +typedef struct AV1FMergeContext { > +CodedBitstreamContext *cbc; > +CodedBitstreamFragment temporal_unit; > +CodedBitstreamFragment frag; > +} AV1FMergeContext; > + > +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *pkt) > +{ > +AV1FMergeContext *ctx = bsf->priv_data; > +CodedBitstreamFragment *frag = &ctx->frag, *tu = &ctx->temporal_unit; > +int err, i; > + > +err = ff_bsf_get_packet_ref(bsf, pkt); > +if (err < 0) { > +if (err == AVERROR_EOF && tu->nb_units > 0) Right now ffmpeg (the cli) does not flush bsf at the end when doing streamcopy. Can you test whether the following patch works with this bsf? https://github.com/mkver/FFmpeg/commit/340a091f5f6b474de096a8b64dd0ce3a8c7f6c24 > +goto eof; > +return err; > +} > + > +err = ff_cbs_read_packet(ctx->cbc, frag, pkt); > +if (err < 0) { > +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); > +goto fail; > +} > + > +if (frag->nb_units == 0) { > +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n"); > +err = AVERROR_INVALIDDATA; > +goto fail; > +} > + > +if (tu->nb_units == 0 && frag->units[0].type != > AV1_OBU_TEMPORAL_DELIMITER) { > +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n"); > +err = AVERROR_INVALIDDATA; > +goto fail; > +} > + > +if (tu->nb_units > 0 && frag->units[0].type == > AV1_OBU_TEMPORAL_DELIMITER) { > +eof: > +err = ff_cbs_write_packet(ctx->cbc, pkt, tu); > +if (err < 0) { > +av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); > +goto fail; > +} > +ff_cbs_fragment_reset(ctx->cbc, tu); > + > +for (i = 0; i < frag->nb_units; i++) { > +if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) { > +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle > of a packet.\n"); > +err = AVERROR_INVALIDDATA; > +goto fail; > +} > +err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, > frag->units[i].type, > + frag->units[i].content, > frag->units[i].content_ref); > +if (err < 0) > +goto
Re: [FFmpeg-devel] [PATCH 5/5] avformat: add an AV1 Annex B demuxer
> Am 11.11.2019 um 22:36 schrieb James Almer : > > +AVInputFormat ff_obu_demuxer = { > +.name = "obu", Why is the demuxer not called “av1”? Thank you, Carl Eugen (Sleepless in Japan) ___ 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 V2] avcodec: add an AV1 frame merge bitstream filter
This BSF takes Temporal Units split across different AVPackets and merges them by looking for Temporal Delimiter OBUs. Signed-off-by: James Almer --- Now copying packet props. configure| 1 + libavcodec/Makefile | 1 + libavcodec/av1_frame_merge_bsf.c | 172 +++ libavcodec/bitstream_filters.c | 1 + 4 files changed, 175 insertions(+) create mode 100644 libavcodec/av1_frame_merge_bsf.c diff --git a/configure b/configure index 1de90e93fd..70f60997c1 100755 --- a/configure +++ b/configure @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp" # bitstream_filters aac_adtstoasc_bsf_select="adts_header" +av1_frame_merge_bsf_select="cbs_av1" av1_frame_split_bsf_select="cbs_av1" av1_metadata_bsf_select="cbs_av1" eac3_core_bsf_select="ac3_parser" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b990c6ba87..006a472a6d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o # bitstream filters OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o mpeg4audio.o OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o diff --git a/libavcodec/av1_frame_merge_bsf.c b/libavcodec/av1_frame_merge_bsf.c new file mode 100644 index 00..72b065b664 --- /dev/null +++ b/libavcodec/av1_frame_merge_bsf.c @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2019 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 "avcodec.h" +#include "bsf.h" +#include "cbs.h" +#include "cbs_av1.h" + +typedef struct AV1FMergeContext { +CodedBitstreamContext *cbc; +CodedBitstreamFragment temporal_unit; +CodedBitstreamFragment frag; +AVPacket *buffer_pkt; +} AV1FMergeContext; + +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) +{ +AV1FMergeContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = &ctx->frag, *tu = &ctx->temporal_unit; +AVPacket *in = NULL; +int err, i; + +err = ff_bsf_get_packet(bsf, &in); +if (err < 0) { +if (err == AVERROR_EOF && tu->nb_units > 0) +goto eof; +return err; +} + +err = ff_cbs_read_packet(ctx->cbc, frag, in); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); +goto fail; +} + +if (frag->nb_units == 0) { +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n"); +err = AVERROR_INVALIDDATA; +goto fail; +} + +if (tu->nb_units == 0 && frag->units[0].type != AV1_OBU_TEMPORAL_DELIMITER) { +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n"); +err = AVERROR_INVALIDDATA; +goto fail; +} + +if (tu->nb_units > 0 && frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) { +eof: +err = ff_cbs_write_packet(ctx->cbc, out, tu); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); +goto fail; +} +err = av_packet_copy_props(out, ctx->buffer_pkt); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to copy packet props.\n"); +goto fail; +} +av_packet_unref(ctx->buffer_pkt); + +ff_cbs_fragment_reset(ctx->cbc, tu); +for (i = 0; i < frag->nb_units; i++) { +if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) { +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of a packet.\n"); +err = AVERROR_INVALIDDATA; +goto fail; +} +err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, frag->units[i].type, + frag->units[i].content, frag->units[i].content_ref); +if (err < 0) +goto fail; +} +ff_cbs_fragment_reset(ctx->cbc, frag); + +if (in) +av_packet_move_ref(ctx->buffer_pkt, in); +av_packet_free(&in); + +return 0;
Re: [FFmpeg-devel] [PATCH 2/5] avcodec: add an AV1 frame merge bitstream filter
On 11/11/2019 12:01 PM, Andreas Rheinhardt wrote: > James Almer: >> This BSF takes Temporal Units split across different AVPackets and merges >> them >> by looking for Temporal Delimiter OBUs. >> >> Signed-off-by: James Almer >> --- >> configure| 1 + >> libavcodec/Makefile | 1 + >> libavcodec/av1_frame_merge_bsf.c | 153 +++ >> libavcodec/bitstream_filters.c | 1 + >> 4 files changed, 156 insertions(+) >> create mode 100644 libavcodec/av1_frame_merge_bsf.c >> >> diff --git a/configure b/configure >> index 1de90e93fd..70f60997c1 100755 >> --- a/configure >> +++ b/configure >> @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp" >> >> # bitstream_filters >> aac_adtstoasc_bsf_select="adts_header" >> +av1_frame_merge_bsf_select="cbs_av1" >> av1_frame_split_bsf_select="cbs_av1" >> av1_metadata_bsf_select="cbs_av1" >> eac3_core_bsf_select="ac3_parser" >> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >> index b990c6ba87..006a472a6d 100644 >> --- a/libavcodec/Makefile >> +++ b/libavcodec/Makefile >> @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o >> # bitstream filters >> OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o >> mpeg4audio.o >> OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o >> +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o >> OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o >> OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o >> OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o >> diff --git a/libavcodec/av1_frame_merge_bsf.c >> b/libavcodec/av1_frame_merge_bsf.c >> new file mode 100644 >> index 00..943cfcb426 >> --- /dev/null >> +++ b/libavcodec/av1_frame_merge_bsf.c >> @@ -0,0 +1,153 @@ >> +/* >> + * Copyright (c) 2019 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 "avcodec.h" >> +#include "bsf.h" >> +#include "cbs.h" >> +#include "cbs_av1.h" >> + >> +typedef struct AV1FMergeContext { >> +CodedBitstreamContext *cbc; >> +CodedBitstreamFragment temporal_unit; >> +CodedBitstreamFragment frag; >> +} AV1FMergeContext; >> + >> +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *pkt) >> +{ >> +AV1FMergeContext *ctx = bsf->priv_data; >> +CodedBitstreamFragment *frag = &ctx->frag, *tu = &ctx->temporal_unit; >> +int err, i; >> + >> +err = ff_bsf_get_packet_ref(bsf, pkt); >> +if (err < 0) { >> +if (err == AVERROR_EOF && tu->nb_units > 0) > > Right now ffmpeg (the cli) does not flush bsf at the end when doing > streamcopy. Yeah, i noticed that when trying to do an av1_frame_split -> av1_frame_merge test run to compare input and output. Also, you just made me realize I'm not copying packet props after the merge. The AV1 parser was doing part of that job for me by flagging key frames within the annexb demuxer, but a cli usage of this bsf wouldn't get that treatment. I fixed that in the V2 i just sent. > Can you test whether the following patch works with this bsf? > https://github.com/mkver/FFmpeg/commit/340a091f5f6b474de096a8b64dd0ce3a8c7f6c24 It does flush on EOF after applying that patch, but there's another issue in do_streamcopy(), where because the first packet (a key frame) is sent to the bsf but not returned until a second packet has been submitted, by the time do_streamcopy() is called that second time, the "!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)" check will fail because ost->frame_number was never bumped to 1, and the second packet is of course not a key frame. You can check that with V2 by trying to do a codec copy with and without -copyinkf. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/5] avformat: add an AV1 Annex B demuxer
On 11/11/2019 2:36 PM, Carl Eugen Hoyos wrote: > > >> Am 11.11.2019 um 22:36 schrieb James Almer : >> >> +AVInputFormat ff_obu_demuxer = { >> +.name = "obu", > > Why is the demuxer not called “av1”? > > Thank you, Carl Eugen > (Sleepless in Japan) I liked obu more, being the extension used for Annex B encapsulated samples, but i'm fine changing it to av1 if others prefer that. The problem will be what to do with the eventual raw Section 5 OBU demuxer. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/mp3dec: replace SAME_HEADER_MASK with MP3_MASK
On Mon, Nov 11, 2019 at 09:05:02AM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > mp3 header bitstream syntax: > header() > { > syncword 12bits bslsf > id 1bitbslsf > layer 2bitbslsf > protection_bit 1bit bslsf > bitrate_index 4bits bslsf > sampling_frequency 2bits bslsf > padding_bit 1bit bslsf > private_bit 1bit bslsf > mode 2bits bslsf > mode_extension 2bits bslsf > copyright 1bit bslsf > original/home 1bit bslsf > emphasis 2bits bslsf > } > > if the header is masking with MP3_MASK(0xFFFE0CCF), below fields will be > cleared: > protection_bit, bitrate_index, sampling_freqency, mode > > with SAME_HEADER_MASK(0xFFFE0C00), extra below fields will be cleared which > didn't make > sense: > mode_extension, copyright, original/home, emphasis > > As the MP3_MASK is good for same mp3 header masking and is defined in the > header, so it's preferable to remove SAME_HEADER_MASK to keep the masking > same. > > Signed-off-by: Limin Wang > --- > libavformat/mp3dec.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) will apply this and the previous patch thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once"- "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." 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 5/5] avformat: add an AV1 Annex B demuxer
James Almer: > Signed-off-by: James Almer > --- > configure| 1 + > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/obu.c| 276 +++ > 4 files changed, 279 insertions(+) > create mode 100644 libavformat/obu.c > > diff --git a/configure b/configure > index 70f60997c1..a8dbba879d 100755 > --- a/configure > +++ b/configure > @@ -3293,6 +3293,7 @@ mxf_d10_muxer_select="mxf_muxer" > mxf_opatom_muxer_select="mxf_muxer" > nut_muxer_select="riffenc" > nuv_demuxer_select="riffdec" > +obu_demuxer_select="av1_frame_merge_bsf" > oga_muxer_select="ogg_muxer" > ogg_demuxer_select="dirac_parse" > ogv_muxer_select="ogg_muxer" > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 8251f8f657..9057d0358a 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -350,6 +350,7 @@ OBJS-$(CONFIG_NULL_MUXER)+= nullenc.o > OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o isom.o > OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o > OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o > +OBJS-$(CONFIG_OBU_DEMUXER) += obu.o > OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ > oggparsecelt.o \ > oggparsedaala.o \ > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index f7fea32b45..152644e9f9 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -282,6 +282,7 @@ extern AVInputFormat ff_nut_demuxer; > extern AVOutputFormat ff_nut_muxer; > extern AVInputFormat ff_nuv_demuxer; > extern AVOutputFormat ff_oga_muxer; > +extern AVInputFormat ff_obu_demuxer; > extern AVInputFormat ff_ogg_demuxer; > extern AVOutputFormat ff_ogg_muxer; > extern AVOutputFormat ff_ogv_muxer; > diff --git a/libavformat/obu.c b/libavformat/obu.c > new file mode 100644 > index 00..55a9c7d55f > --- /dev/null > +++ b/libavformat/obu.c > @@ -0,0 +1,276 @@ > +/* > + * AV1 Annex-B demuxer > + * Copyright (c) 2019 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 "config.h" > + > +#include "libavutil/common.h" > +#include "libavutil/opt.h" > +#include "libavcodec/av1_parse.h" > +#include "avformat.h" > +#include "avio_internal.h" > +#include "internal.h" > + > +typedef struct AnnexBContext { > +const AVClass *class; > +AVBSFContext *bsf; > +uint32_t temporal_unit_size; > +uint32_t frame_unit_size; > +AVRational framerate; > +} AnnexBContext; > + > +static int leb(AVIOContext *pb, uint32_t *len) { > +int more, i = 0; > +uint8_t byte; > +*len = 0; > +do { > +unsigned bits; > +byte = avio_r8(pb); > +more = byte & 0x80; > +bits = byte & 0x7f; > +if (i <= 3 || (i == 4 && bits < (1 << 4))) > +*len |= bits << (i * 7); > +else if (bits) > +return AVERROR_INVALIDDATA; > +if (++i == 8 && more) > +return AVERROR_INVALIDDATA; > +if (pb->eof_reached || pb->error) > +return pb->error ? pb->error : AVERROR(EIO); > +} while (more); > +return i; > +} > + > +static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int > *type) > +{ > +int start_pos, temporal_id, spatial_id; > +int len; > + > +len = parse_obu_header(buf, size, obu_size, &start_pos, > + type, &temporal_id, &spatial_id); > +if (len < 0) > +return len; > + > +return 0; > +} > + > +static int annexb_probe(const AVProbeData *p) > +{ > +AVIOContext pb; > +int64_t obu_size; > +uint32_t temporal_unit_size, frame_unit_size, obu_unit_size; > +int seq = 0, frame_header = 0; > +int ret, type, cnt = 0; > + > +ffio_init_context(&pb, p->buf, p->buf_size, 0, > + NULL, NULL, NULL, NULL); > + > +ret = leb(&pb, &temporal_unit_size); > +if (ret < 0) > +return 0; > +cnt += ret; > +ret = leb(&pb, &frame_unit_size); > +if (ret < 0 || (frame_unit_size + ret) > temporal_unit_size) > +return 0; > +cnt += ret; > +temporal_
Re: [FFmpeg-devel] [PATCH 5/5] avformat: add an AV1 Annex B demuxer
On 11/11/2019 4:28 PM, Andreas Rheinhardt wrote: > James Almer: >> Signed-off-by: James Almer >> --- >> configure| 1 + >> libavformat/Makefile | 1 + >> libavformat/allformats.c | 1 + >> libavformat/obu.c| 276 +++ >> 4 files changed, 279 insertions(+) >> create mode 100644 libavformat/obu.c >> >> diff --git a/configure b/configure >> index 70f60997c1..a8dbba879d 100755 >> --- a/configure >> +++ b/configure >> @@ -3293,6 +3293,7 @@ mxf_d10_muxer_select="mxf_muxer" >> mxf_opatom_muxer_select="mxf_muxer" >> nut_muxer_select="riffenc" >> nuv_demuxer_select="riffdec" >> +obu_demuxer_select="av1_frame_merge_bsf" >> oga_muxer_select="ogg_muxer" >> ogg_demuxer_select="dirac_parse" >> ogv_muxer_select="ogg_muxer" >> diff --git a/libavformat/Makefile b/libavformat/Makefile >> index 8251f8f657..9057d0358a 100644 >> --- a/libavformat/Makefile >> +++ b/libavformat/Makefile >> @@ -350,6 +350,7 @@ OBJS-$(CONFIG_NULL_MUXER)+= nullenc.o >> OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o isom.o >> OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o >> OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o >> +OBJS-$(CONFIG_OBU_DEMUXER) += obu.o >> OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ >> oggparsecelt.o \ >> oggparsedaala.o \ >> diff --git a/libavformat/allformats.c b/libavformat/allformats.c >> index f7fea32b45..152644e9f9 100644 >> --- a/libavformat/allformats.c >> +++ b/libavformat/allformats.c >> @@ -282,6 +282,7 @@ extern AVInputFormat ff_nut_demuxer; >> extern AVOutputFormat ff_nut_muxer; >> extern AVInputFormat ff_nuv_demuxer; >> extern AVOutputFormat ff_oga_muxer; >> +extern AVInputFormat ff_obu_demuxer; >> extern AVInputFormat ff_ogg_demuxer; >> extern AVOutputFormat ff_ogg_muxer; >> extern AVOutputFormat ff_ogv_muxer; >> diff --git a/libavformat/obu.c b/libavformat/obu.c >> new file mode 100644 >> index 00..55a9c7d55f >> --- /dev/null >> +++ b/libavformat/obu.c >> @@ -0,0 +1,276 @@ >> +/* >> + * AV1 Annex-B demuxer >> + * Copyright (c) 2019 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 "config.h" >> + >> +#include "libavutil/common.h" >> +#include "libavutil/opt.h" >> +#include "libavcodec/av1_parse.h" >> +#include "avformat.h" >> +#include "avio_internal.h" >> +#include "internal.h" >> + >> +typedef struct AnnexBContext { >> +const AVClass *class; >> +AVBSFContext *bsf; >> +uint32_t temporal_unit_size; >> +uint32_t frame_unit_size; >> +AVRational framerate; >> +} AnnexBContext; >> + >> +static int leb(AVIOContext *pb, uint32_t *len) { >> +int more, i = 0; >> +uint8_t byte; >> +*len = 0; >> +do { >> +unsigned bits; >> +byte = avio_r8(pb); >> +more = byte & 0x80; >> +bits = byte & 0x7f; >> +if (i <= 3 || (i == 4 && bits < (1 << 4))) >> +*len |= bits << (i * 7); >> +else if (bits) >> +return AVERROR_INVALIDDATA; >> +if (++i == 8 && more) >> +return AVERROR_INVALIDDATA; >> +if (pb->eof_reached || pb->error) >> +return pb->error ? pb->error : AVERROR(EIO); >> +} while (more); >> +return i; >> +} >> + >> +static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int >> *type) >> +{ >> +int start_pos, temporal_id, spatial_id; >> +int len; >> + >> +len = parse_obu_header(buf, size, obu_size, &start_pos, >> + type, &temporal_id, &spatial_id); >> +if (len < 0) >> +return len; >> + >> +return 0; >> +} >> + >> +static int annexb_probe(const AVProbeData *p) >> +{ >> +AVIOContext pb; >> +int64_t obu_size; >> +uint32_t temporal_unit_size, frame_unit_size, obu_unit_size; >> +int seq = 0, frame_header = 0; >> +int ret, type, cnt = 0; >> + >> +ffio_init_context(&pb, p->buf, p->buf_size, 0, >> + NULL, NULL, NULL, NULL); >> + >> +ret = leb(&pb, &temporal_unit_size); >> +if (ret < 0) >> +retur
Re: [FFmpeg-devel] [PATCH 2/5] avcodec: add an AV1 frame merge bitstream filter
James Almer: > On 11/11/2019 12:01 PM, Andreas Rheinhardt wrote: >> James Almer: >>> This BSF takes Temporal Units split across different AVPackets and merges >>> them >>> by looking for Temporal Delimiter OBUs. >>> >>> Signed-off-by: James Almer >>> --- >>> configure| 1 + >>> libavcodec/Makefile | 1 + >>> libavcodec/av1_frame_merge_bsf.c | 153 +++ >>> libavcodec/bitstream_filters.c | 1 + >>> 4 files changed, 156 insertions(+) >>> create mode 100644 libavcodec/av1_frame_merge_bsf.c >>> >>> diff --git a/configure b/configure >>> index 1de90e93fd..70f60997c1 100755 >>> --- a/configure >>> +++ b/configure >>> @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp" >>> >>> # bitstream_filters >>> aac_adtstoasc_bsf_select="adts_header" >>> +av1_frame_merge_bsf_select="cbs_av1" >>> av1_frame_split_bsf_select="cbs_av1" >>> av1_metadata_bsf_select="cbs_av1" >>> eac3_core_bsf_select="ac3_parser" >>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >>> index b990c6ba87..006a472a6d 100644 >>> --- a/libavcodec/Makefile >>> +++ b/libavcodec/Makefile >>> @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o >>> # bitstream filters >>> OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o >>> mpeg4audio.o >>> OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o >>> +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o >>> OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o >>> OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o >>> OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o >>> diff --git a/libavcodec/av1_frame_merge_bsf.c >>> b/libavcodec/av1_frame_merge_bsf.c >>> new file mode 100644 >>> index 00..943cfcb426 >>> --- /dev/null >>> +++ b/libavcodec/av1_frame_merge_bsf.c >>> @@ -0,0 +1,153 @@ >>> +/* >>> + * Copyright (c) 2019 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 "avcodec.h" >>> +#include "bsf.h" >>> +#include "cbs.h" >>> +#include "cbs_av1.h" >>> + >>> +typedef struct AV1FMergeContext { >>> +CodedBitstreamContext *cbc; >>> +CodedBitstreamFragment temporal_unit; >>> +CodedBitstreamFragment frag; >>> +} AV1FMergeContext; >>> + >>> +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *pkt) >>> +{ >>> +AV1FMergeContext *ctx = bsf->priv_data; >>> +CodedBitstreamFragment *frag = &ctx->frag, *tu = &ctx->temporal_unit; >>> +int err, i; >>> + >>> +err = ff_bsf_get_packet_ref(bsf, pkt); >>> +if (err < 0) { >>> +if (err == AVERROR_EOF && tu->nb_units > 0) >> >> Right now ffmpeg (the cli) does not flush bsf at the end when doing >> streamcopy. > > Yeah, i noticed that when trying to do an av1_frame_split -> > av1_frame_merge test run to compare input and output. > > Also, you just made me realize I'm not copying packet props after the > merge. The AV1 parser was doing part of that job for me by flagging key > frames within the annexb demuxer, but a cli usage of this bsf wouldn't > get that treatment. I fixed that in the V2 i just sent. > >> Can you test whether the following patch works with this bsf? >> https://github.com/mkver/FFmpeg/commit/340a091f5f6b474de096a8b64dd0ce3a8c7f6c24 > > It does flush on EOF after applying that patch, but there's another > issue in do_streamcopy(), where because the first packet (a key frame) > is sent to the bsf but not returned until a second packet has been > submitted, by the time do_streamcopy() is called that second time, the > "!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)" check will fail > because ost->frame_number was never bumped to 1, and the second packet > is of course not a key frame. > > You can check that with V2 by trying to do a codec copy with and without > -copyinkf. I am well aware of that: https://github.com/mkver/FFmpeg/commit/f94e1b062a125e7de2a9f12c09e9a3894263b309 contains a workaround for this for vp9_raw_reorder. Will look into your new version soon. - Andreas PS: Even with this patch ffmpeg cli does not flush when it stops because of the limits (e.g. -t or -to time has bee
Re: [FFmpeg-devel] [PATCH] librav1e: Don't make users explicitly set -qp -1 to use bit rate mode
On 11/11/2019 11:16 AM, Derek Buitenhuis wrote: > Signed-off-by: Derek Buitenhuis > --- > libavcodec/librav1e.c | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c > index 5052cac896..11c1d09e36 100644 > --- a/libavcodec/librav1e.c > +++ b/libavcodec/librav1e.c > @@ -329,6 +329,10 @@ static av_cold int librav1e_encode_init(AVCodecContext > *avctx) > } > } > > +/* We can't easily represent this behavior with AVOptions, so do it > here. */ > +if (!avctx->bit_rate && ctx->quantizer < 0) > +ctx->quantizer = 100; Looks like the default of 100 is done in the library itself, if rav1e_config_parse_int() isn't called for either quantizer or bitrate. If you remove this chunk and leave the one below, the output bitstreams when calling this encoder with no arguments vs using -qp 100 are the same. > + > if (avctx->bit_rate && ctx->quantizer < 0) { > int max_quantizer = avctx->qmax >= 0 ? avctx->qmax : 255; > > @@ -533,7 +537,7 @@ retry: > #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM > > static const AVOption options[] = { > -{ "qp", "use constant quantizer mode", OFFSET(quantizer), > AV_OPT_TYPE_INT, { .i64 = 100 }, -1, 255, VE }, > +{ "qp", "use constant quantizer mode (defaults to 100 if no bit rate is > set)", OFFSET(quantizer), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, VE }, > { "speed", "what speed preset to use", OFFSET(speed), AV_OPT_TYPE_INT, { > .i64 = -1 }, -1, 10, VE }, > { "tiles", "number of tiles encode with", OFFSET(tiles), > AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE }, > { "tile-rows", "number of tiles rows to encode with", OFFSET(tile_rows), > AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE }, ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC PATCH v2] avutil/frame: fix remove_side_data
On Sun, 10 Nov 2019, Marton Balint wrote: On Sun, 3 Nov 2019, Zhao Zhili wrote: remove_side_data is supposed to remove a single instance by design. Since new_side_data() doesn't forbid add multiple instances of the same type, remove_side_data should deal with that. --- I'm afraid this patch makes it harder to enforce single entry per type. libavutil/frame.c | 2 +- libavutil/frame.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) Thanks, I will apply this soon. Thanks, applied. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5 V2] avcodec: add an AV1 frame merge bitstream filter
James Almer: > This BSF takes Temporal Units split across different AVPackets and merges them > by looking for Temporal Delimiter OBUs. > > Signed-off-by: James Almer > --- > Now copying packet props. > > configure| 1 + > libavcodec/Makefile | 1 + > libavcodec/av1_frame_merge_bsf.c | 172 +++ > libavcodec/bitstream_filters.c | 1 + > 4 files changed, 175 insertions(+) > create mode 100644 libavcodec/av1_frame_merge_bsf.c > > diff --git a/configure b/configure > index 1de90e93fd..70f60997c1 100755 > --- a/configure > +++ b/configure > @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp" > > # bitstream_filters > aac_adtstoasc_bsf_select="adts_header" > +av1_frame_merge_bsf_select="cbs_av1" > av1_frame_split_bsf_select="cbs_av1" > av1_metadata_bsf_select="cbs_av1" > eac3_core_bsf_select="ac3_parser" > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index b990c6ba87..006a472a6d 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o > # bitstream filters > OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o mpeg4audio.o > OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o > +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o > OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o > OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o > OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o > diff --git a/libavcodec/av1_frame_merge_bsf.c > b/libavcodec/av1_frame_merge_bsf.c > new file mode 100644 > index 00..72b065b664 > --- /dev/null > +++ b/libavcodec/av1_frame_merge_bsf.c > @@ -0,0 +1,172 @@ > +/* > + * Copyright (c) 2019 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 "avcodec.h" > +#include "bsf.h" > +#include "cbs.h" > +#include "cbs_av1.h" > + > +typedef struct AV1FMergeContext { > +CodedBitstreamContext *cbc; > +CodedBitstreamFragment temporal_unit; > +CodedBitstreamFragment frag; > +AVPacket *buffer_pkt; > +} AV1FMergeContext; > + > +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) > +{ > +AV1FMergeContext *ctx = bsf->priv_data; > +CodedBitstreamFragment *frag = &ctx->frag, *tu = &ctx->temporal_unit; > +AVPacket *in = NULL; > +int err, i; > + > +err = ff_bsf_get_packet(bsf, &in); The allocation that is implicit in ff_bsf_get_packet() can be avoided by putting an AVPacket on the stack here and using this for reading; or even better: Directly read into buffer_pkt if tu->nb_units vanishes and read into the other packet in the other case. Or you can use two buffer_pkt and switch between them; this should eliminate all av_packet_move_ref(). > +if (err < 0) { > +if (err == AVERROR_EOF && tu->nb_units > 0) > +goto eof; > +return err; > +} > + > +err = ff_cbs_read_packet(ctx->cbc, frag, in); > +if (err < 0) { > +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); > +goto fail; > +} > + > +if (frag->nb_units == 0) { > +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n"); > +err = AVERROR_INVALIDDATA; > +goto fail; > +} > + > +if (tu->nb_units == 0 && frag->units[0].type != > AV1_OBU_TEMPORAL_DELIMITER) { > +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n"); > +err = AVERROR_INVALIDDATA; > +goto fail; > +} > + > +if (tu->nb_units > 0 && frag->units[0].type == > AV1_OBU_TEMPORAL_DELIMITER) { > +eof: > +err = ff_cbs_write_packet(ctx->cbc, out, tu); There are some complications here with respect to OBU units for which decomposition is unimplemented (i.e. the reserved types): In contrast to cbs_h2645, cbs_jpeg and cbs_mpeg2 cbs_av1 sets the content of all the units it reads, even for those that it can't decompose. cbs_read_fragment_content() then emits its "Decomposition unimplemented" warning, but it doesn't forward the error. So you end up with a unit with content where the content doesn't contain the information to rebuild the unit. Writing them will fail with AVERR
Re: [FFmpeg-devel] [PATCH] avformat/mxfenc: simplify dv ul handling
lör 2019-11-09 klockan 15:46 -0800 skrev Baptiste Coudurier: > +static const UID mxf_dv_container_uls[] = { > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x01,0x01 > }, // IEC DV25 525/60 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x02,0x01 > }, // IEC DV25 626/50 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x40,0x01 > }, // DV25 525/60 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 > }, // DV25 625/50 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x50,0x01 > }, // DV50 525/60 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x51,0x01 > }, // DV50 625/50 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x60,0x01 > }, // DV100 1080/60 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x61,0x01 > }, // DV100 1080/50 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x62,0x01 > }, // DV100 720/60 > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x63,0x01 > }, // DV100 720/50 > +}; > + > +static const UID mxf_dv_codec_uls[] = { > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x01,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x01,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x02,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x03,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x04,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x05,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x06,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x07,0x00 > }, > +{ > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x08,0x00 > }, > +}; Maybe a struct to keep these two together, or a comment saying they correspond to eachother 1:1 > static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket > *pkt) > { > MXFContext *mxf = s->priv_data; > MXFStreamContext *sc = st->priv_data; > uint8_t *vs_pack, *vsc_pack; > +int apt = pkt->data[4] & 0x7; Can pkt->data ever be less than 5 bytes? > @@ -2182,28 +2144,29 @@ static int mxf_parse_dv_frame(AVFormatContext *s, > AVStream *st, AVPacket *pkt) > > switch (stype) { > case 0x18: // DV100 720p > -ul_index = INDEX_DV100_720_50 + pal; > +ul_index = 8+pal; Not a huge fan of magic constants. Maybe just move the INDEX_DV* enums to their own enum? Could use array index initializers to enforce that they're indeed in the right spots in mxf_dv_*_uls[]. Combined with the struct suggestion: static const struct { UID container_ul, codec_ul; } dv_uls[] = { [INDEX_DV25_525_60] = {{0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x01,0x01}, {0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x01,0x00}}, //... }; /Tomas ___ 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] avformat/mxfenc: correctly set width values for dvcprohd
lör 2019-11-09 klockan 15:46 -0800 skrev Baptiste Coudurier: > --- > libavformat/mxfenc.c | 15 --- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c > index b7ae5cc637..f7df9c3daf 100644 > --- a/libavformat/mxfenc.c > +++ b/libavformat/mxfenc.c > @@ -1092,7 +1092,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext > *s, AVStream *st, const UID > { > MXFStreamContext *sc = st->priv_data; > AVIOContext *pb = s->pb; > -int stored_width = (st->codecpar->width +15)/16*16; > +int stored_width = 0; > int stored_height = (st->codecpar->height+15)/16*16; > int display_height; > int f1, f2; > @@ -1101,6 +1101,15 @@ static int64_t mxf_write_cdci_common(AVFormatContext > *s, AVStream *st, const UID > > get_trc(transfer_ul, st->codecpar->color_trc); > > +if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) { > +if (st->codecpar->height == 1080) > +stored_width = 1920; > +else if (st->codecpar->height == 720) > +stored_width = 1280; What about the other DV variants? > +} > +if (!stored_width) > +stored_width = (st->codecpar->width+15)/16*16; Shouldn't this have SAR applied? /Tomas ___ 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 V2] avcodec: add an AV1 frame merge bitstream filter
On 11/11/2019 7:45 PM, Andreas Rheinhardt wrote: > James Almer: >> This BSF takes Temporal Units split across different AVPackets and merges >> them >> by looking for Temporal Delimiter OBUs. >> >> Signed-off-by: James Almer >> --- >> Now copying packet props. >> >> configure| 1 + >> libavcodec/Makefile | 1 + >> libavcodec/av1_frame_merge_bsf.c | 172 +++ >> libavcodec/bitstream_filters.c | 1 + >> 4 files changed, 175 insertions(+) >> create mode 100644 libavcodec/av1_frame_merge_bsf.c >> >> diff --git a/configure b/configure >> index 1de90e93fd..70f60997c1 100755 >> --- a/configure >> +++ b/configure >> @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp" >> >> # bitstream_filters >> aac_adtstoasc_bsf_select="adts_header" >> +av1_frame_merge_bsf_select="cbs_av1" >> av1_frame_split_bsf_select="cbs_av1" >> av1_metadata_bsf_select="cbs_av1" >> eac3_core_bsf_select="ac3_parser" >> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >> index b990c6ba87..006a472a6d 100644 >> --- a/libavcodec/Makefile >> +++ b/libavcodec/Makefile >> @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o >> # bitstream filters >> OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o >> mpeg4audio.o >> OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o >> +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o >> OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o >> OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o >> OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o >> diff --git a/libavcodec/av1_frame_merge_bsf.c >> b/libavcodec/av1_frame_merge_bsf.c >> new file mode 100644 >> index 00..72b065b664 >> --- /dev/null >> +++ b/libavcodec/av1_frame_merge_bsf.c >> @@ -0,0 +1,172 @@ >> +/* >> + * Copyright (c) 2019 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 "avcodec.h" >> +#include "bsf.h" >> +#include "cbs.h" >> +#include "cbs_av1.h" >> + >> +typedef struct AV1FMergeContext { >> +CodedBitstreamContext *cbc; >> +CodedBitstreamFragment temporal_unit; >> +CodedBitstreamFragment frag; >> +AVPacket *buffer_pkt; >> +} AV1FMergeContext; >> + >> +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) >> +{ >> +AV1FMergeContext *ctx = bsf->priv_data; >> +CodedBitstreamFragment *frag = &ctx->frag, *tu = &ctx->temporal_unit; >> +AVPacket *in = NULL; >> +int err, i; >> + >> +err = ff_bsf_get_packet(bsf, &in); > > The allocation that is implicit in ff_bsf_get_packet() can be avoided > by putting an AVPacket on the stack here and using this for reading; > or even better: Directly read into buffer_pkt if tu->nb_units vanishes > and read into the other packet in the other case. Or you can use two > buffer_pkt and switch between them; this should eliminate all > av_packet_move_ref(). I'm purposely avoiding storing AVPackets on stack, or using sizeof(AVPacket) altogether. Afaik we want to make them behave like AVFrames in the long term, and that starts by not adding more code that will have to be adapted eventually. I do agree an alternative using an extra AVPacket in AV1FMergeContext may be worth looking into to instead use ff_bsf_get_packet_ref() here. > >> +if (err < 0) { >> +if (err == AVERROR_EOF && tu->nb_units > 0) >> +goto eof; >> +return err; >> +} >> + >> +err = ff_cbs_read_packet(ctx->cbc, frag, in); >> +if (err < 0) { >> +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); >> +goto fail; >> +} >> + >> +if (frag->nb_units == 0) { >> +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n"); >> +err = AVERROR_INVALIDDATA; >> +goto fail; >> +} >> + >> +if (tu->nb_units == 0 && frag->units[0].type != >> AV1_OBU_TEMPORAL_DELIMITER) { >> +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n"); >> +err = AVERROR_INVALIDDATA; >> +goto fail; >> +} >> + >> +if (tu->nb_units > 0 && frag->units[0].type == >> AV1_OBU_TEMPORAL_DELIMITER) { >> +eof: >> +err = ff
[FFmpeg-devel] [PATCH] avformat/mxfenc: simplify dv ul handling
--- libavformat/mxfenc.c | 128 --- 1 file changed, 46 insertions(+), 82 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index aa23ee3947..5e987488f6 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -83,6 +83,7 @@ typedef struct MXFStreamContext { UID track_essence_element_key; int index; ///< index in mxf_essence_container_uls table const UID *codec_ul; +const UID *container_ul; int order; ///< interleaving order if dts are equal int interlaced; ///< whether picture is interlaced int field_dominance; ///< tff=1, bff=2 @@ -135,16 +136,6 @@ enum ULIndex { INDEX_D10_525_60_30_VIDEO, INDEX_D10_525_60_30_AUDIO, INDEX_DV, -INDEX_DV25_525_60, -INDEX_DV25_625_50, -INDEX_DV25_525_60_IEC, -INDEX_DV25_625_50_IEC, -INDEX_DV50_525_60, -INDEX_DV50_625_50, -INDEX_DV100_1080_60, -INDEX_DV100_1080_50, -INDEX_DV100_720_60, -INDEX_DV100_720_50, INDEX_DNXHD, INDEX_JPEG2000, INDEX_H264, @@ -242,64 +233,11 @@ static const MXFContainerEssenceEntry mxf_essence_container_uls[] = { { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x06,0x01,0x10,0x00 }, { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x00,0x00,0x00,0x00 }, mxf_write_generic_sound_desc }, -// DV Unknown +// DV { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x7F,0x01 }, { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x00,0x00,0x00 }, mxf_write_cdci_desc }, - -// DV25 525/60 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x40,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x01,0x00 }, - mxf_write_cdci_desc }, -// DV25 625/50 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x02,0x00 }, - mxf_write_cdci_desc }, - -// IEC DV25 525/60 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x01,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x01,0x00 }, - mxf_write_cdci_desc }, -// IEC DV25 625/50 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x02,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, - mxf_write_cdci_desc }, - - // DV50 525/60 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x50,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x03,0x00 }, - mxf_write_cdci_desc }, -// DV50 625/50 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x51,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x04,0x00 }, - mxf_write_cdci_desc }, -// DV100 1080/60 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x60,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x05,0x00 }, - mxf_write_cdci_desc }, -// DV100 1080/50 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x61,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x06,0x00 }, - mxf_write_cdci_desc }, -// DV100 720/60 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x62,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x07,0x00 }, - mxf_write_cdci_desc }, -// DV100 720/50 -{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x63,0x01 }, - { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x18,0x01,0x01,0x00 }, - { 0x06,
Re: [FFmpeg-devel] [PATCH] lavf/mov: initial support for reading HEIF images
On Fri, Nov 1, 2019 at 4:46 PM Carl Eugen Hoyos wrote: > Testing would be helpful. > > Works for AVIF after adding the line I proposed as well as setting codecpar->width/height for the stream based on ispe. Breaks AVIFS files that were previously demuxing as mp4 w/ video track, i.e., https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix/avifs. As such might end up causing some client issues for MP4s that had embedded pict elements, but are not HEIF/AVIF - since they'll suddenly start surfacing new tracks. - dale ___ 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] avformat/mxfenc: correctly set width values for dvcprohd
> On Nov 11, 2019, at 3:30 PM, Tomas Härdin wrote: > > lör 2019-11-09 klockan 15:46 -0800 skrev Baptiste Coudurier: >> --- >> libavformat/mxfenc.c | 15 --- >> 1 file changed, 12 insertions(+), 3 deletions(-) >> >> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c >> index b7ae5cc637..f7df9c3daf 100644 >> --- a/libavformat/mxfenc.c >> +++ b/libavformat/mxfenc.c >> @@ -1092,7 +1092,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext >> *s, AVStream *st, const UID >> { >> MXFStreamContext *sc = st->priv_data; >> AVIOContext *pb = s->pb; >> -int stored_width = (st->codecpar->width +15)/16*16; >> +int stored_width = 0; >> int stored_height = (st->codecpar->height+15)/16*16; >> int display_height; >> int f1, f2; >> @@ -1101,6 +1101,15 @@ static int64_t mxf_write_cdci_common(AVFormatContext >> *s, AVStream *st, const UID >> >> get_trc(transfer_ul, st->codecpar->color_trc); >> >> +if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) { >> +if (st->codecpar->height == 1080) >> +stored_width = 1920; >> +else if (st->codecpar->height == 720) >> +stored_width = 1280; > > What about the other DV variants? These get default value >> +} >> +if (!stored_width) >> +stored_width = (st->codecpar->width+15)/16*16; > > Shouldn't this have SAR applied? I didn’t change this, the code was like that before — Baptiste ___ 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] avformat/mxfenc: simplify dv ul handling
Hi Thomas, > On Nov 11, 2019, at 3:17 PM, Tomas Härdin wrote: > > lör 2019-11-09 klockan 15:46 -0800 skrev Baptiste Coudurier: >> +static const UID mxf_dv_container_uls[] = { >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x01,0x01 >> }, // IEC DV25 525/60 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x02,0x01 >> }, // IEC DV25 626/50 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x40,0x01 >> }, // DV25 525/60 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 >> }, // DV25 625/50 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x50,0x01 >> }, // DV50 525/60 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x51,0x01 >> }, // DV50 625/50 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x60,0x01 >> }, // DV100 1080/60 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x61,0x01 >> }, // DV100 1080/50 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x62,0x01 >> }, // DV100 720/60 >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x63,0x01 >> }, // DV100 720/50 >> +}; >> + >> +static const UID mxf_dv_codec_uls[] = { >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x01,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x01,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x02,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x03,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x04,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x05,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x06,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x07,0x00 >> }, >> +{ >> 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x08,0x00 >> }, >> +}; > > Maybe a struct to keep these two together, or a comment saying they > correspond to eachother 1:1 > >> static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket >> *pkt) >> { >> MXFContext *mxf = s->priv_data; >> MXFStreamContext *sc = st->priv_data; >> uint8_t *vs_pack, *vsc_pack; >> +int apt = pkt->data[4] & 0x7; > > Can pkt->data ever be less than 5 bytes? > >> @@ -2182,28 +2144,29 @@ static int mxf_parse_dv_frame(AVFormatContext *s, >> AVStream *st, AVPacket *pkt) >> >> switch (stype) { >> case 0x18: // DV100 720p >> -ul_index = INDEX_DV100_720_50 + pal; >> +ul_index = 8+pal; > > Not a huge fan of magic constants. Maybe just move the INDEX_DV* enums > to their own enum? Could use array index initializers to enforce that > they're indeed in the right spots in mxf_dv_*_uls[]. Combined with the > struct suggestion: > > static const struct { > UID container_ul, codec_ul; > } dv_uls[] = { > [INDEX_DV25_525_60] = > {{0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x01,0x01}, > > {0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x01,0x00}}, > //... > }; That would defeat the purpose of the patch, getting rid of the useless constants :) — Baptiste ___ 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 v2] avformat: add an AV1 Annex B demuxer
Signed-off-by: James Almer --- configure| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/obu.c| 277 +++ 4 files changed, 280 insertions(+) create mode 100644 libavformat/obu.c diff --git a/configure b/configure index 70f60997c1..a8dbba879d 100755 --- a/configure +++ b/configure @@ -3293,6 +3293,7 @@ mxf_d10_muxer_select="mxf_muxer" mxf_opatom_muxer_select="mxf_muxer" nut_muxer_select="riffenc" nuv_demuxer_select="riffdec" +obu_demuxer_select="av1_frame_merge_bsf" oga_muxer_select="ogg_muxer" ogg_demuxer_select="dirac_parse" ogv_muxer_select="ogg_muxer" diff --git a/libavformat/Makefile b/libavformat/Makefile index 8251f8f657..9057d0358a 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -350,6 +350,7 @@ OBJS-$(CONFIG_NULL_MUXER)+= nullenc.o OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o isom.o OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o +OBJS-$(CONFIG_OBU_DEMUXER) += obu.o OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ oggparsecelt.o \ oggparsedaala.o \ diff --git a/libavformat/allformats.c b/libavformat/allformats.c index f7fea32b45..152644e9f9 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -282,6 +282,7 @@ extern AVInputFormat ff_nut_demuxer; extern AVOutputFormat ff_nut_muxer; extern AVInputFormat ff_nuv_demuxer; extern AVOutputFormat ff_oga_muxer; +extern AVInputFormat ff_obu_demuxer; extern AVInputFormat ff_ogg_demuxer; extern AVOutputFormat ff_ogg_muxer; extern AVOutputFormat ff_ogv_muxer; diff --git a/libavformat/obu.c b/libavformat/obu.c new file mode 100644 index 00..a8ba8a26f4 --- /dev/null +++ b/libavformat/obu.c @@ -0,0 +1,277 @@ +/* + * AV1 Annex B demuxer + * Copyright (c) 2019 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 "config.h" + +#include "libavutil/common.h" +#include "libavutil/opt.h" +#include "libavcodec/av1_parse.h" +#include "avformat.h" +#include "avio_internal.h" +#include "internal.h" + +typedef struct AnnexBContext { +const AVClass *class; +AVBSFContext *bsf; +uint32_t temporal_unit_size; +uint32_t frame_unit_size; +AVRational framerate; +} AnnexBContext; + +static int leb(AVIOContext *pb, uint32_t *len) { +int more, i = 0; +uint8_t byte; +*len = 0; +do { +unsigned bits; +byte = avio_r8(pb); +more = byte & 0x80; +bits = byte & 0x7f; +if (i <= 3 || (i == 4 && bits < (1 << 4))) +*len |= bits << (i * 7); +else if (bits) +return AVERROR_INVALIDDATA; +if (++i == 8 && more) +return AVERROR_INVALIDDATA; +if (pb->eof_reached || pb->error) +return pb->error ? pb->error : AVERROR(EIO); +} while (more); +return i; +} + +static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int *type) +{ +int start_pos, temporal_id, spatial_id; +int len; + +len = parse_obu_header(buf, size, obu_size, &start_pos, + type, &temporal_id, &spatial_id); +if (len < 0) +return len; + +return 0; +} + +static int annexb_probe(const AVProbeData *p) +{ +AVIOContext pb; +int64_t obu_size; +uint32_t temporal_unit_size, frame_unit_size, obu_unit_size; +int seq = 0, frame_header = 0; +int ret, type, cnt = 0; + +ffio_init_context(&pb, p->buf, p->buf_size, 0, + NULL, NULL, NULL, NULL); + +ret = leb(&pb, &temporal_unit_size); +if (ret < 0) +return 0; +cnt += ret; +ret = leb(&pb, &frame_unit_size); +if (ret < 0 || ((int64_t)frame_unit_size + ret) > temporal_unit_size) +return 0; +cnt += ret; +temporal_unit_size -= ret; +ret = leb(&pb, &obu_unit_size); +if (ret < 0 || ((int64_t)obu_unit_size + ret) >= frame_unit_size) +return 0; +cnt += ret; + +temporal_unit_size -= obu_unit_size + ret; +frame_unit_size -= obu_unit_size + ret; + +avio_skip(&pb, obu_unit_size); +
Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device
On Mon, 11. Nov 07:05, Carl Eugen Hoyos wrote: > > > > Am 11.11.2019 um 04:42 schrieb Andriy Gelman : > > > > +/* check configured pix_fmt matches avctx->pix_fmt */ > > Is this comment really useful? ok, will remove > > > +pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, > > AV_CODEC_ID_RAWVIDEO); > > +if (pix_fmt_output != avctx->pix_fmt) { > > +const AVPixFmtDescriptor *desc = > > av_pix_fmt_desc_get(pix_fmt_output); > > +av_log(priv, AV_LOG_ERROR, "Pixel format not configured. Encoder > > requires %s " > > > > + " pixel format. On command line add > > setting:" > > + " -pix_fmt %s to force correct pixel > > format.\n", > > This should be rarely printed by a library, I don’t think this is a good > exception. I thought it would be useful to tell the user how to solve the problem. I can modify the docs instead and add option -list_pix_fmt that tells the user what pixel formats are supported? -- Andriy ___ 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 V2] avcodec: add an AV1 frame merge bitstream filter
On 11/11/2019 8:36 PM, James Almer wrote: >>> +for (i = 0; i < frag->nb_units; i++) { >>> +if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) { >>> +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of >>> a packet.\n"); >>> +err = AVERROR_INVALIDDATA; >>> +goto fail; >>> +} >>> +err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, >>> frag->units[i].type, >>> + frag->units[i].content, >>> frag->units[i].content_ref); >> You make new references to content and then immediately thereafter >> unref the old ones. How about adding a function that moves a unit (or >> several units at once) from one fragment to another? > A new function that moves units sounds good. Shouldn't be hard to > implement either, i think. So a unit move function would require a memcpy for the unit from one fragment to another, a memset to 0 on the source unit, then a call to ff_cbs_delete_unit() which memmoves the remaining units to fill the gap created by the removed one, if any. I don't know if it's that much better than this current implementation creating a new AVBufferRef per unit, then wiping the whole source fragment in one go. ___ 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] avcodec/v4l2_m2m_dec: Fix decoding on Odroid XU4
From: Andriy Gelman c0c79461967 unintentianally changed the initialization flow of the decoder: It caused the capture buffers to be initialized on v4l2_m2m.c:180 in v4l2_configure_contexts(). This breaks h264 decoding on the Odroid XU4 (RPI4 was not affected). This commit postpones capture buffer initialization as before c0c79461967 to fix the issue. Signed-off-by: Andriy Gelman --- libavcodec/v4l2_m2m_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index 4712aca34c2..83d506b6b09 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -201,6 +201,7 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) capture->av_codec_id = AV_CODEC_ID_RAWVIDEO; capture->av_pix_fmt = avctx->pix_fmt; +s->avctx = avctx; ret = ff_v4l2_m2m_codec_init(priv); if (ret) { av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n"); @@ -209,7 +210,6 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) return ret; } -s->avctx = avctx; return v4l2_prepare_decoder(s); } -- 2.23.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] avcodec/v4l2_context: Fix indentation
From: Andriy Gelman Signed-off-by: Andriy Gelman --- libavcodec/v4l2_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 874761752cb..bdc2b841530 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -717,8 +717,8 @@ int ff_v4l2_context_init(V4L2Context* ctx) ctx->num_buffers = req.count; ctx->buffers = av_mallocz(ctx->num_buffers * sizeof(V4L2Buffer)); if (!ctx->buffers) { -av_log(logger(ctx), AV_LOG_ERROR, "%s malloc enomem\n", ctx->name); -return AVERROR(ENOMEM); +av_log(logger(ctx), AV_LOG_ERROR, "%s malloc enomem\n", ctx->name); +return AVERROR(ENOMEM); } for (i = 0; i < req.count; i++) { -- 2.23.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/5 v2] avformat: add an AV1 Annex B demuxer
Hi, On Mon, Nov 11, 2019 at 9:17 PM James Almer wrote: > +static int leb(AVIOContext *pb, uint32_t *len) { > this can overflow, should be uint64_t. > +unsigned bits; > Same. Ronald ___ 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".