Re: [FFmpeg-devel] [PATCH] avcodec/mpeg12enc: replace return -1 with proper error codes
lance.lmw...@gmail.com (12020-05-07): > Yeah, then I had to change the ff_mpv_encode_init() return with accurate > error code also. If necessary yes. But it can be done later if you have other priorities. But I consider better to correctly forward an invalid error code than to incorrectly invent a new error code. One would be fixed later, the other not. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/fifo: add options to slow down writing packets to match real time approximately
On Thu, 7 May 2020, leozhang wrote: Suggested-by: Nicolas George Reviewed-by: Nicolas George Reviewed-by: Marton Balint Reviewed-by: Andreas Rheinhardt You seem to misunderstand the use of this tag. You should only add these if you received an explict LGTM for your patches. This has not happened here, you only got suggestions, and those suggestions were concerning your earlier patch versions. Also, what happened to the suggestion of using a buffer based approach and using realtime only for flushing? I will code something, and see how it goes, and will post a result as an RFC patch. Regards, Marton Signed-off-by: leozhang --- doc/muxers.texi| 21 + libavformat/fifo.c | 46 ++ 2 files changed, 67 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 536433b..14528f1 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2274,6 +2274,17 @@ certain (usually permanent) errors the recovery is not attempted even when Specify whether to wait for the keyframe after recovering from queue overflow or failure. This option is set to 0 (false) by default. +@item realtime @var{bool} +If set to 1 (true), slow down writing packets to match real time approximately. +This is similar to @ref{the realtime or arealtime filters,,the "realtime_002c-arealtime" section in the ffmpeg-filters manual,ffmpeg-filters}. +Please note that in some cases without filtering, such as stream copy, you can also use it. + +@item realtime_speed +It is the same as the speed option to realtime or arealtime filters. + +@item realtime_limit @var{duration} +It is the same as the limit option to realtime or arealtime filters. + @end table @subsection Examples @@ -2291,6 +2302,16 @@ ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv -map 0:v -map 0 @end itemize +@itemize + +@item +Stream something to rtmp server, instead of using -re option. +@example +ffmpeg -i your_input_file -c copy -map 0:v -map 0:a -f fifo -fifo_format flv -realtime 1 rtmp://example.com/live/stream_name +@end example + +@end itemize + @anchor{tee} @section tee diff --git a/libavformat/fifo.c b/libavformat/fifo.c index d11dc66..7acc420 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -26,6 +26,7 @@ #include "libavutil/threadmessage.h" #include "avformat.h" #include "internal.h" +#include #define FIFO_DEFAULT_QUEUE_SIZE 60 #define FIFO_DEFAULT_MAX_RECOVERY_ATTEMPTS 0 @@ -77,6 +78,17 @@ typedef struct FifoContext { /* Value > 0 signals queue overflow */ volatile uint8_t overflow_flag; +/* Slow down writing packets to match real time approximately */ +int realtime; + +/* Speed factor for the processing when realtime */ +double realtime_speed; + +/* Time limit for the pauses when realtime */ +int64_t realtime_limit; + +int64_t delta; +unsigned inited; } FifoContext; typedef struct FifoThreadContext { @@ -183,6 +195,31 @@ static int fifo_thread_write_packet(FifoThreadContext *ctx, AVPacket *pkt) dst_tb = avf2->streams[s_idx]->time_base; av_packet_rescale_ts(pkt, src_tb, dst_tb); +if (fifo->realtime) { +int64_t pts = av_rescale_q(pkt->dts, dst_tb, AV_TIME_BASE_Q) / fifo->realtime_speed; +int64_t now = av_gettime_relative(); +int64_t sleep = pts - now + fifo->delta; + +if (!fifo->inited) { +sleep = 0; +fifo->delta = now - pts; +fifo->inited = 1; +} + +if (FFABS(sleep) > fifo->realtime_limit / fifo->realtime_speed) { +av_log(avf, AV_LOG_WARNING, "time discontinuity detected: %"PRIi64" us, resetting\n", sleep); +sleep = 0; +fifo->delta = now - pts; +} + +if (sleep > 0) { +av_log(avf, AV_LOG_DEBUG, "sleeping %"PRIi64" us\n", sleep); +for (; sleep > 6; sleep -= 6) +av_usleep(6); +av_usleep(sleep); +} +} + ret = av_write_frame(avf2, pkt); if (ret >= 0) av_packet_unref(pkt); @@ -630,6 +667,15 @@ static const AVOption options[] = { {"recover_any_error", "Attempt recovery regardless of type of the error", OFFSET(recover_any_error), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, +{"realtime", "Slow down writing packets to match real time approximately", OFFSET(realtime), + AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, + +{"realtime_speed", "Speed factor for the processing when realtime", OFFSET(realtime_speed), + AV_OPT_TYPE_DOUBLE, {.dbl = 1.0}, DBL_MIN, DBL_MAX, AV_OPT_FLAG_ENCODING_PARAM}, + +{"realtime_limit", "Time limit for the pauses when realtime", OFFSET(realtime_limit), + AV_OPT_TYPE_DURATION, {.i64 = 200}, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM}, + {NULL}, }; -- 1.8.3.1 ___
Re: [FFmpeg-devel] [PATCH 3/3] avcodec/exr: add option to output pixels in float
Quoting Mark Reid (2020-05-07 03:16:17) > On Wed, May 6, 2020 at 1:07 PM Anton Khirnov wrote: > > > Quoting mindm...@gmail.com (2020-04-29 05:02:35) > > > From: Mark Reid > > > > > > --- > > > libavcodec/exr.c | 103 +++ > > > 1 file changed, 86 insertions(+), 17 deletions(-) > > > > > > diff --git a/libavcodec/exr.c b/libavcodec/exr.c > > > @@ -1888,6 +1955,8 @@ static const AVOption options[] = { > > > AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD }, > > > { "gamma", "Set the float gamma value when decoding", OFFSET(gamma), > > > AV_OPT_TYPE_FLOAT, { .dbl = 1.0f }, 0.001, FLT_MAX, VD }, > > > +{ "float", "Output frame in floating point pixel format, apply_trc > > does not get applied", OFFSET(output_float), > > > +AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD}, > > > > Wouldn't it make more sense to export the coded format rather than have > > an option like this? > > > > > I could do that, I just was worried about breaking any user's use case. But > now that I think about it, I don't think it would, and I think that would > be simpler. Yes, if swscale supports this then it shouldn't cause problems. I believe the general rule is that decoders should export the native format inasmuch as possible and avoid doing conversion internally. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/hlsenc: move init file write code block to hls_write_header
Signed-off-by: Steven Liu --- libavformat/hlsenc.c | 37 - 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 5695c6cc95..a1eddade7b 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2266,6 +2266,26 @@ static int hls_write_header(AVFormatContext *s) } } } +if (hls->segment_type == SEGMENT_TYPE_FMP4 && !vs->init_range_length) { +int range_length = 0; +int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0); +av_write_frame(vs->avf, NULL); /* Flush any buffered data */ +avio_tell(vs->avf->pb); +avio_flush(vs->avf->pb); +range_length = avio_close_dyn_buf(vs->avf->pb, &vs->init_buffer); +if (range_length <= 0) +return AVERROR(EINVAL); +avio_write(vs->out, vs->init_buffer, range_length); +if (!hls->resend_init_file) +av_freep(&vs->init_buffer); +vs->init_range_length = range_length; +avio_open_dyn_buf(&vs->avf->pb); +vs->packets_written = 0; +vs->start_pos = range_length; +if (!byterange_mode) { +hlsenc_io_close(s, &vs->out, vs->base_output_dirname); +} +} } return ret; @@ -2383,23 +2403,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) new_start_pos = avio_tell(oc->pb); vs->size = new_start_pos - vs->start_pos; avio_flush(oc->pb); -if (hls->segment_type == SEGMENT_TYPE_FMP4) { -if (!vs->init_range_length) { -range_length = avio_close_dyn_buf(oc->pb, &vs->init_buffer); -if (range_length <= 0) -return AVERROR(EINVAL); -avio_write(vs->out, vs->init_buffer, range_length); -if (!hls->resend_init_file) -av_freep(&vs->init_buffer); -vs->init_range_length = range_length; -avio_open_dyn_buf(&oc->pb); -vs->packets_written = 0; -vs->start_pos = range_length; -if (!byterange_mode) { -hlsenc_io_close(s, &vs->out, vs->base_output_dirname); -} -} -} if (!byterange_mode) { if (vs->vtt_avf) { hlsenc_io_close(s, &vs->vtt_avf->pb, vs->vtt_avf->url); -- 2.25.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] Revert "doc/mailing-list-faq: Mention current problem with GMX"
mails to GMX seem working again This reverts commit cd11fbcfb03994d3ddbc83f0620530d6f6748f68. --- doc/mailing-list-faq.texi | 4 1 file changed, 4 deletions(-) diff --git a/doc/mailing-list-faq.texi b/doc/mailing-list-faq.texi index 15fc8e86c0..439d783956 100644 --- a/doc/mailing-list-faq.texi +++ b/doc/mailing-list-faq.texi @@ -358,10 +358,6 @@ often not aware of this and is often out of their control. When possible we attempt to notify the provider to be removed from the blacklists or filters. -Currently (End April/May 2020) GMX is apparently blocking all mails from FFmpeg. -If you have a gmx account, do not hesitate to complain to them about this. We so far -have had no luck. - @section Why are my sent messages not showing up? Excluding @ref{Why is my message awaiting moderator approval?, messages that are held in the moderation queue} -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/mpegts: Shuffle avio_seek
This avoids accessing an old, no longer valid buffer. Fixes: out of array access Fixes: crash_audio-2020 Found-by: le wu Signed-off-by: Michael Niedermayer --- libavformat/mpegts.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 0833d62ea5..a065c61c40 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2881,15 +2881,16 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren AVIOContext *pb = s->pb; int c, i; uint64_t pos = avio_tell(pb); - -avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR); +int64_t back = FFMIN(seekback, pos); //Special case for files like 01c56b0dc1.ts if (current_packet[0] == 0x80 && current_packet[12] == 0x47) { -avio_seek(pb, 12, SEEK_CUR); +avio_seek(pb, 12 - back, SEEK_CUR); return 0; } +avio_seek(pb, -back, SEEK_CUR); + for (i = 0; i < ts->resync_size; i++) { c = avio_r8(pb); if (avio_feof(pb)) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/5] avcodec/mpegvideo_enc: reindent code
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index b2eb9cf..e1fd92c 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -596,8 +596,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if ((s->codec_id == AV_CODEC_ID_WMV1 || s->codec_id == AV_CODEC_ID_WMV2) && avctx->width & 1) { - av_log(avctx, AV_LOG_ERROR, "width must be multiple of 2\n"); - return -1; +av_log(avctx, AV_LOG_ERROR, "width must be multiple of 2\n"); +return -1; } if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME)) && -- 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] [PATCH v2 3/5] avcodec/mpeg12enc: return more specific error codes for encode_init()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpeg12enc.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 643ba81..cab7076 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -139,16 +139,17 @@ static int find_frame_rate_index(MpegEncContext *s) static av_cold int encode_init(AVCodecContext *avctx) { +int ret; MpegEncContext *s = avctx->priv_data; -if (ff_mpv_encode_init(avctx) < 0) -return -1; +if ((ret = ff_mpv_encode_init(avctx)) < 0) +return ret; if (find_frame_rate_index(s) < 0) { if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(avctx, AV_LOG_ERROR, "MPEG-1/2 does not support %d/%d fps\n", avctx->time_base.den, avctx->time_base.num); -return -1; +return AVERROR(EINVAL); } else { av_log(avctx, AV_LOG_INFO, "MPEG-1/2 does not support %d/%d fps, there may be AV sync issues\n", @@ -159,7 +160,7 @@ static av_cold int encode_init(AVCodecContext *avctx) if (avctx->profile == FF_PROFILE_UNKNOWN) { if (avctx->level != FF_LEVEL_UNKNOWN) { av_log(avctx, AV_LOG_ERROR, "Set profile and level\n"); -return -1; +return AVERROR(EINVAL); } /* Main or 4:2:2 */ avctx->profile = s->chroma_format == CHROMA_420 ? FF_PROFILE_MPEG2_MAIN : FF_PROFILE_MPEG2_422; @@ -175,7 +176,7 @@ static av_cold int encode_init(AVCodecContext *avctx) if (avctx->profile != FF_PROFILE_MPEG2_HIGH && s->chroma_format != CHROMA_420) { av_log(avctx, AV_LOG_ERROR, "Only High(1) and 4:2:2(0) profiles support 4:2:2 color sampling\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->width <= 720 && avctx->height <= 576) avctx->level = 8; /* Main */ @@ -205,7 +206,7 @@ static av_cold int encode_init(AVCodecContext *avctx) if (s->drop_frame_timecode && s->frame_rate_index != 4) { av_log(avctx, AV_LOG_ERROR, "Drop frame time code only allowed with 1001/3 fps\n"); -return -1; +return AVERROR(EINVAL); } #if FF_API_PRIVATE_OPT -- 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] [PATCH v2 2/5] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo_enc.c | 85 +++--- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e1fd92c..45aa82f 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->pix_fmt != AV_PIX_FMT_YUV422P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 and YUV422 are supported\n"); -return -1; +return AVERROR(EINVAL); } break; case AV_CODEC_ID_MJPEG: @@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if (!format_supported) { av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n"); -return -1; +return AVERROR(EINVAL); } break; default: if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); -return -1; +return AVERROR(EINVAL); } } @@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or neither must be specified\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { @@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_max_rate && @@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->bit_rate * (int64_t)avctx->time_base.num > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (!s->fixed_qscale && @@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P && s->codec_id != AV_CODEC_ID_FLV1) { av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decision\n"); -return -1; +return AVERROR(EINVAL); } if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->max_b_frames&& @@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->max_b_frames < 0) { av_log(avctx, AV_LOG_ERROR, "max b frames must be 0 or positive for mpegvideo based encoders\n"); -return -1; +return AVERROR(EINVAL); } if ((s->codec_id == AV_CODEC_ID_MPEG4 || @@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS (avctx->width > 2048 || avctx->height > 1152 )) { av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions above 2048x1152\n"); -return -1; +return AVERROR(EINVAL); } if ((s->codec_id == AV_CODEC_ID_H263 || s->codec_id == AV_CODEC_ID_H263P) && ((avctx->width &3) || (avctx->height&3) )) { av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO && (avctx->width > 4095 || avctx->height > 4095 )) { av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions above 4095x4095\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && (avctx->width > 16383 || avctx->height > 16383 )) { av_log(avctx, AV_LOG_ERROR, "MPEG-2 does not support resolutions above 16383x16383\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_RV10 && @@ -597,13 +597,13 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id == AV_CODEC_I
[FFmpeg-devel] [PATCH v2 4/5] avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 22cab28..b5ddb1b 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -889,7 +889,7 @@ static void clear_context(MpegEncContext *s) */ av_cold int ff_mpv_common_init(MpegEncContext *s) { -int i, ret; +int i, ret = AVERROR(ENOMEM); int nb_slices = (HAVE_THREADS && s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; @@ -907,7 +907,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { av_log(s->avctx, AV_LOG_ERROR, "decoding to AV_PIX_FMT_NONE is not supported.\n"); -return -1; +return AVERROR(EINVAL); } if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) { @@ -923,7 +923,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if ((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) -return -1; +return AVERROR(EINVAL); dct_init(s); @@ -954,7 +954,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (!s->new_picture.f) goto fail; -if (init_context_frame(s)) +if ((ret = init_context_frame(s))) goto fail; s->parse_context.state = -1; @@ -971,7 +971,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (!s->thread_context[i]) goto fail; } -if (init_duplicate_context(s->thread_context[i]) < 0) +if ((ret = init_duplicate_context(s->thread_context[i])) < 0) goto fail; s->thread_context[i]->start_mb_y = (s->mb_height * (i) + nb_slices / 2) / nb_slices; @@ -979,7 +979,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; } } else { -if (init_duplicate_context(s) < 0) +if ((ret = init_duplicate_context(s)) < 0) goto fail; s->start_mb_y = 0; s->end_mb_y = s->mb_height; @@ -990,7 +990,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) return 0; fail: ff_mpv_common_end(s); -return -1; +return ret; } /** -- 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] [PATCH v2 5/5] avcodec/mpegvideo: return more specific error codes for init_duplicate_context()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index b5ddb1b..8a74a45 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -359,7 +359,7 @@ static int init_duplicate_context(MpegEncContext *s) int y_size = s->b8_stride * (2 * s->mb_height + 1); int c_size = s->mb_stride * (s->mb_height + 1); int yc_size = y_size + 2 * c_size; -int i; +int i, ret = AVERROR(ENOMEM); if (s->mb_height & 1) yc_size += 2*s->b8_stride + 2*s->mb_stride; @@ -408,7 +408,7 @@ static int init_duplicate_context(MpegEncContext *s) return 0; fail: -return -1; // free() through ff_mpv_common_end() +return ret; // free() through ff_mpv_common_end() } static void free_duplicate_context(MpegEncContext *s) -- 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] [WIP PATCH 2/2] checkasm: add hscale test
This tests the hscale 8bpp to 14bpp functions with different filter sizes. Signed-off-by: Josh de Kock --- Not quite ready to be committed but I wanted to submit it anyway so I could get some comments. I still need to do the rest of the scale sizes (such as 8bpp to 19bpp) and make the benchmarks work. tests/checkasm/Makefile| 2 +- tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/sw_hscale.c | 108 + 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 tests/checkasm/sw_hscale.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index de850c016e..c04c2a304e 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -45,7 +45,7 @@ AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) # swscale tests -SWSCALEOBJS += sw_rgb.o +SWSCALEOBJS += sw_hscale.o sw_rgb.o CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index d67147ae6f..8bf32d5b65 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -182,6 +182,7 @@ static const struct { #endif #endif #if CONFIG_SWSCALE +{ "sw_scale", checkasm_check_sw_scale }, { "sw_rgb", checkasm_check_sw_rgb }, #endif #if CONFIG_AVUTIL diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 0a7f9f25c4..98d59aedf7 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -68,6 +68,7 @@ void checkasm_check_opusdsp(void); void checkasm_check_pixblockdsp(void); void checkasm_check_sbrdsp(void); void checkasm_check_synth_filter(void); +void checkasm_check_sw_scale(void); void checkasm_check_sw_rgb(void); void checkasm_check_utvideodsp(void); void checkasm_check_v210dec(void); diff --git a/tests/checkasm/sw_hscale.c b/tests/checkasm/sw_hscale.c new file mode 100644 index 00..f54ed72d81 --- /dev/null +++ b/tests/checkasm/sw_hscale.c @@ -0,0 +1,108 @@ +/* + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +#include "checkasm.h" + +#define randomize_buffers(buf, size) \ +do { \ +int j;\ +for (j = 0; j < size; j+=4) \ +AV_WN32(buf + j, rnd()); \ +} while (0) + +#define MAX_WIDTH 128 +#define MAX_FILTER_WIDTH 40 + +#define INIT_FILTER(bsrc, bdst, width) \ +ctx->srcBpc = bsrc; \ +ctx->dstBpc = bdst; \ +ctx->hLumFilterSize = ctx->hChrFilterSize = width; \ +for (i = 0; i < MAX_WIDTH; i++) { \ +filterPos[i] = i; \ +for (j = 0; j < width; j++) { \ +filter[i * width + j] = (1 << 14) / width; \ +} \ +} \ +\ +for (i = 0; i < MAX_FILTER_WIDTH; i++) { \ +filter[MAX_WIDTH * width + i] = (1 << 14) / width; \ +} \ +ff_getSwsFunc(ctx); + +#define CHECK_FILTER(width) \ +INIT_FILTER(8, 14, width) \ +if (check_func(ctx->hcScale, "hscale_8_to_15_width" #width)) { \ +memset(dst0, 0, MAX_WIDTH * sizeof(dst0[0])); \ +memset(dst1, 0, MAX_WIDTH * sizeof(dst1[0])); \ +\ +call_ref(NULL, dst0, MAX_WIDTH, src, filter, filterPos, width); \ +call_new(NULL, dst1, MAX_WIDTH, src, filter, filterPos, width); \ +if (memcmp(dst0, dst1, MAX_WIDTH)) \ +fail(); \ +/*bench_new();*/ \ +} + +static void check_hscale(void) +{ +int i, j; +struct SwsContext *ctx; + +// padded +LOCAL_ALIGNED_32(uint8_t, src, [MAX_WIDTH + MAX_FILTER_WIDTH - 1]); +LOCAL_ALIGNED_32(uint16_t, dst0, [MAX_WIDTH]); +LOCAL_ALIGNED_32(uint16_t, dst1, [MAX_WIDTH]); + +// padded +LOCAL_ALIGNED_32(int16_t, filter, [MAX_WIDTH * MAX_FILTER_WIDTH + MAX_FILTER_WIDTH]); +LOCAL_ALIGNED_32(int32_t, filterPos, [MAX_WIDTH]); + +declare_func(void, void*c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int fil
[FFmpeg-devel] [PATCH 1/2] swscale: fix NEON hscale init
The NEON hscale function only supports X8 filter sizes and should only be selected when these are being used. Signed-off-by: Josh de Kock --- libswscale/aarch64/swscale.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index 54a3beabe8..eecbea88ca 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -34,7 +34,10 @@ av_cold void ff_sws_init_swscale_aarch64(SwsContext *c) int cpu_flags = av_get_cpu_flags(); if (have_neon(cpu_flags)) { -if (c->srcBpc == 8 && c->dstBpc <= 14) { +if (c->srcBpc == 8 && c->dstBpc <= 14 && +(c->hLumFilterSize % 8) == 0 && +(c->hChrFilterSize % 8) == 0) +{ c->hyScale = c->hcScale = ff_hscale_8_to_15_neon; } if (c->dstBpc == 8) { -- 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".
Re: [FFmpeg-devel] [PATCH v3] libavcodec/libx264: fix reference frame computation based on level
On 05/05/2020 17:02, Fu, Linjie wrote: From: ffmpeg-devel On Behalf Of Josh Brewster Sent: Tuesday, May 5, 2020 23:52 To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH v3] libavcodec/libx264: fix reference frame computation based on level From: ffmpeg-devel ffmpeg-devel-boun...@ffmpeg.org On Behalf Of Josh de Kock Sent: Tuesday, April 28, 2020 23:47 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH v3] libavcodec/libx264: fix reference frame computation based on level On 26/04/2020 12:46, Josh Brewster wrote: Hi, is there anything else I need to do to have this merged? From a precursory look at what x264 and we're doing here your patch is correct. It doesn't break from a quick test, and looks OK to me. Would rather someone else has a look at it too but I will again in a couple days if no one does. Should be ok IMHO, thx. - Linjie Thanks for the feedback, I'll wait for it to be merged then. FYI, already merged several days ago with the help of Josh in: https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/79f001675a2bae16e243f30a3e7de9da6aeb3c2d Ah, it seems my 'Patch applied' email never came though. Yes, I merged this. -- Josh ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/5] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
lance.lmw...@gmail.com (12020-05-07): > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/mpegvideo_enc.c | 85 > +++--- > 1 file changed, 43 insertions(+), 42 deletions(-) > > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c > index e1fd92c..45aa82f 100644 > --- a/libavcodec/mpegvideo_enc.c > +++ b/libavcodec/mpegvideo_enc.c > @@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > avctx->pix_fmt != AV_PIX_FMT_YUV422P) { > av_log(avctx, AV_LOG_ERROR, > "only YUV420 and YUV422 are supported\n"); > -return -1; > +return AVERROR(EINVAL); > } > break; > case AV_CODEC_ID_MJPEG: > @@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > > if (!format_supported) { > av_log(avctx, AV_LOG_ERROR, "colorspace not supported in > jpeg\n"); > -return -1; > +return AVERROR(EINVAL); > } > break; > default: > if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { > av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); > -return -1; > +return AVERROR(EINVAL); > } > } > > @@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { > av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or > neither must be specified\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { > @@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > > if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { > av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { > av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (avctx->rc_max_rate && > @@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > avctx->bit_rate * (int64_t)avctx->time_base.num > > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { > av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (!s->fixed_qscale && > @@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS > s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P > && > s->codec_id != AV_CODEC_ID_FLV1) { > av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { > av_log(avctx, AV_LOG_ERROR, > "OBMC is only supported with simple mb decision\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { > av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->max_b_frames&& > @@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > s->codec_id != AV_CODEC_ID_MPEG1VIDEO && > s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { > av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); > -return -1; > +return AVERROR(EINVAL); > } > if (s->max_b_frames < 0) { > av_log(avctx, AV_LOG_ERROR, > "max b frames must be 0 or positive for mpegvideo based > encoders\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if ((s->codec_id == AV_CODEC_ID_MPEG4 || > @@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS > (avctx->width > 2048 || > avctx->height > 1152 )) { > av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions > above 2048x1152\n"); > -return -1; > +return AVERROR(EINVAL); > } > if ((s->codec_id == AV_CODEC_ID_H263 || > s->codec_id == AV_CODEC_ID_H263P) && > ((avctx->width &3) || > (avctx->height&3) )) { > av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO && > (avctx->width > 4095 || > avctx->height > 4095 )) { > av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions > above 4095x4095\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && > (avctx->width > 16383 || >
Re: [FFmpeg-devel] [PATCH] avformat/dashdec: compute the segment size use current pos minus offset plus one
> 2020年5月6日 下午3:09,myp...@gmail.com 写道: > > On Wed, May 6, 2020 at 2:53 PM Steven Liu wrote: >> >> because the offset should use one byte >> >> Reported-by: Zhao Jun > >> Signed-off-by: Steven Liu >> --- >> libavformat/dashdec.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c >> index 5ba7feb245..04a1baea15 100644 >> --- a/libavformat/dashdec.c >> +++ b/libavformat/dashdec.c >> @@ -590,7 +590,7 @@ static struct fragment * get_Fragment(char *range) >> char *str_end_offset; >> char *str_offset = av_strtok(range, "-", &str_end_offset); >> seg->url_offset = strtoll(str_offset, NULL, 10); >> -seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset; >> +seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset + 1; >> } >> >> return seg; >> -- >> 2.25.0 > > LGTM, tested and verified > Applied Thanks Steven Liu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [WIP PATCH 2/2] checkasm: add hscale test
On Thu, 7 May 2020, Josh de Kock wrote: This tests the hscale 8bpp to 14bpp functions with different filter sizes. Signed-off-by: Josh de Kock --- Not quite ready to be committed but I wanted to submit it anyway so I could get some comments. I still need to do the rest of the scale sizes (such as 8bpp to 19bpp) and make the benchmarks work. Not a proper review, but some comments just from reading it diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index de850c016e..c04c2a304e 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -45,7 +45,7 @@ AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) # swscale tests -SWSCALEOBJS += sw_rgb.o +SWSCALEOBJS += sw_hscale.o sw_rgb.o Nitpick: The object file is called sw_hscale here, but the functions just sw_scale - can it be made consistent? diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index d67147ae6f..8bf32d5b65 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -182,6 +182,7 @@ static const struct { #endif #endif #if CONFIG_SWSCALE +{ "sw_scale", checkasm_check_sw_scale }, { "sw_rgb", checkasm_check_sw_rgb }, Alphabetical order? #endif #if CONFIG_AVUTIL diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 0a7f9f25c4..98d59aedf7 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -68,6 +68,7 @@ void checkasm_check_opusdsp(void); void checkasm_check_pixblockdsp(void); void checkasm_check_sbrdsp(void); void checkasm_check_synth_filter(void); +void checkasm_check_sw_scale(void); void checkasm_check_sw_rgb(void); Nit: These seem to be in alphabetical order here void checkasm_check_utvideodsp(void); void checkasm_check_v210dec(void); diff --git a/tests/checkasm/sw_hscale.c b/tests/checkasm/sw_hscale.c new file mode 100644 index 00..f54ed72d81 --- /dev/null +++ b/tests/checkasm/sw_hscale.c @@ -0,0 +1,108 @@ +/* + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +#include "checkasm.h" + +#define randomize_buffers(buf, size) \ +do { \ +int j;\ +for (j = 0; j < size; j+=4) \ Nit: Space around operators at the end +AV_WN32(buf + j, rnd()); \ +} while (0) + +#define MAX_WIDTH 128 +#define MAX_FILTER_WIDTH 40 + +#define INIT_FILTER(bsrc, bdst, width) \ +ctx->srcBpc = bsrc; \ +ctx->dstBpc = bdst; \ +ctx->hLumFilterSize = ctx->hChrFilterSize = width; \ +for (i = 0; i < MAX_WIDTH; i++) { \ +filterPos[i] = i; \ +for (j = 0; j < width; j++) { \ +filter[i * width + j] = (1 << 14) / width; \ Would be great to test with a filter that doesn't have the same coefficient everywhere - this can easily let many implementation bugs slip through +} \ +} \ +\ +for (i = 0; i < MAX_FILTER_WIDTH; i++) { \ +filter[MAX_WIDTH * width + i] = (1 << 14) / width; \ +} \ Isn't this last bit here just padding for simd implementations that might overread? In that case it shouldn't matter what we set here - and certainly not seemingly valid filter coefficients? +ff_getSwsFunc(ctx); + +#define CHECK_FILTER(width) \ +INIT_FILTER(8, 14, width) \ +if (check_func(ctx->hcScale, "hscale_8_to_15_width" #width)) { \ Can't this just be made into a proper loop instead of a macro that is expanded multiple times? check_func takes a format string, so you can make it "..._width%d", width). Just add an array of the widths to check and iterate over that. +memset(dst0, 0, MAX_WIDTH * sizeof(dst0[0])); \ +memset(dst1, 0, MAX_WIDTH * sizeof(dst1[0])); \ +\ +call_ref(NULL, dst0, MAX_WIDTH, src, filter, filterPos, width); \ +call_new(NULL, dst1, MAX_WIDTH, src, filter, filterPos, width); \ Shouldn't you pass the sws context as the first argument here? In case an implementation would store anything of value there
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Shuffle avio_seek
Quoting Michael Niedermayer (2020-05-07 12:38:26) > This avoids accessing an old, no longer valid buffer. > Fixes: out of array access > Fixes: crash_audio-2020 > > Found-by: le wu > Signed-off-by: Michael Niedermayer > --- > libavformat/mpegts.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > index 0833d62ea5..a065c61c40 100644 > --- a/libavformat/mpegts.c > +++ b/libavformat/mpegts.c > @@ -2881,15 +2881,16 @@ static int mpegts_resync(AVFormatContext *s, int > seekback, const uint8_t *curren > AVIOContext *pb = s->pb; > int c, i; > uint64_t pos = avio_tell(pb); > - > -avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR); > +int64_t back = FFMIN(seekback, pos); > > //Special case for files like 01c56b0dc1.ts > if (current_packet[0] == 0x80 && current_packet[12] == 0x47) { > -avio_seek(pb, 12, SEEK_CUR); > +avio_seek(pb, 12 - back, SEEK_CUR); > return 0; > } > > +avio_seek(pb, -back, SEEK_CUR); > + This seems pretty non-obvious - why would ordering seeks in a specific way result in invalid memorry access? -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/profiles: remove duplicate FF_PROFILE_RESERVED entry
Quoting lance.lmw...@gmail.com (2020-05-05 16:43:10) > From: Limin Wang > > Signed-off-by: Limin Wang > --- Looks good. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] closed caption decoder: accept and decode a new codec type of 'raw 608 byte pairs'
Quoting Roger Pack (2020-04-28 08:15:19) > From 5d7c12a3f703e794e1092087355bc9523d5f4d93 Mon Sep 17 00:00:00 2001 > From: rogerdpack > Date: Tue, 28 Apr 2020 05:15:15 + > Subject: [PATCH 1/3] closed caption decoder: accept and decode a new codec > type of 'raw 608 byte pairs' > > Signed-off-by: rogerdpack > --- > diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h > index e7d6e059db..805e18758b 100644 > --- a/libavcodec/codec_id.h > +++ b/libavcodec/codec_id.h > @@ -513,6 +513,7 @@ enum AVCodecID { > > AV_CODEC_ID_MICRODVD = 0x17800, > AV_CODEC_ID_EIA_608, > +AV_CODEC_ID_EIA_608_RAW_BYTE_PAIRS, You can't just add new IDs in the middle of the table, it changes the IDs of all the following codecs which breaks ABI. Add it to the end of the subtitle block. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/5] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
On Thu, May 07, 2020 at 01:30:02PM +0200, Nicolas George wrote: > lance.lmw...@gmail.com (12020-05-07): > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/mpegvideo_enc.c | 85 > > +++--- > > 1 file changed, 43 insertions(+), 42 deletions(-) > > > > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c > > index e1fd92c..45aa82f 100644 > > --- a/libavcodec/mpegvideo_enc.c > > +++ b/libavcodec/mpegvideo_enc.c > > @@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > > avctx->pix_fmt != AV_PIX_FMT_YUV422P) { > > av_log(avctx, AV_LOG_ERROR, > > "only YUV420 and YUV422 are supported\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > break; > > case AV_CODEC_ID_MJPEG: > > @@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > > > > if (!format_supported) { > > av_log(avctx, AV_LOG_ERROR, "colorspace not supported in > > jpeg\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > break; > > default: > > if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { > > av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > } > > > > @@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > > > if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { > > av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate > > or neither must be specified\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { > > @@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > > > > if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { > > av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { > > av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (avctx->rc_max_rate && > > @@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > avctx->bit_rate * (int64_t)avctx->time_base.num > > > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { > > av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (!s->fixed_qscale && > > @@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS > > s->codec_id != AV_CODEC_ID_H263 && s->codec_id != > > AV_CODEC_ID_H263P && > > s->codec_id != AV_CODEC_ID_FLV1) { > > av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { > > av_log(avctx, AV_LOG_ERROR, > > "OBMC is only supported with simple mb decision\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { > > av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->max_b_frames&& > > @@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > > s->codec_id != AV_CODEC_ID_MPEG1VIDEO && > > s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { > > av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > if (s->max_b_frames < 0) { > > av_log(avctx, AV_LOG_ERROR, > > "max b frames must be 0 or positive for mpegvideo based > > encoders\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if ((s->codec_id == AV_CODEC_ID_MPEG4 || > > @@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS > > (avctx->width > 2048 || > > avctx->height > 1152 )) { > > av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions > > above 2048x1152\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > if ((s->codec_id == AV_CODEC_ID_H263 || > > s->codec_id == AV_CODEC_ID_H263P) && > > ((avctx->width &3) || > > (avctx->height&3) )) { > > av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO && > > (avctx
Re: [FFmpeg-devel] [PATCH 1/3] closed caption decoder: accept and decode a new codec type of 'raw 608 byte pairs'
Is it just me, or the coded id is too much verbose? On 5/7/20, Anton Khirnov wrote: > Quoting Roger Pack (2020-04-28 08:15:19) >> From 5d7c12a3f703e794e1092087355bc9523d5f4d93 Mon Sep 17 00:00:00 2001 >> From: rogerdpack >> Date: Tue, 28 Apr 2020 05:15:15 + >> Subject: [PATCH 1/3] closed caption decoder: accept and decode a new codec >> type of 'raw 608 byte pairs' >> >> Signed-off-by: rogerdpack >> --- >> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h >> index e7d6e059db..805e18758b 100644 >> --- a/libavcodec/codec_id.h >> +++ b/libavcodec/codec_id.h >> @@ -513,6 +513,7 @@ enum AVCodecID { >> >> AV_CODEC_ID_MICRODVD = 0x17800, >> AV_CODEC_ID_EIA_608, >> +AV_CODEC_ID_EIA_608_RAW_BYTE_PAIRS, > > You can't just add new IDs in the middle of the table, it changes the > IDs of all the following codecs which breaks ABI. > Add it to the end of the subtitle block. > > -- > Anton Khirnov > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/profiles: remove duplicate FF_PROFILE_RESERVED entry
On Thu, May 07, 2020 at 02:14:07PM +0200, Anton Khirnov wrote: > Quoting lance.lmw...@gmail.com (2020-05-05 16:43:10) > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > Looks good. will apply. > > -- > Anton Khirnov > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ 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 v3 2/5] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo_enc.c | 85 +++--- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e1fd92c..bb7ac88 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->pix_fmt != AV_PIX_FMT_YUV422P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 and YUV422 are supported\n"); -return -1; +return AVERROR(EINVAL); } break; case AV_CODEC_ID_MJPEG: @@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if (!format_supported) { av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n"); -return -1; +return AVERROR(EINVAL); } break; default: if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); -return -1; +return AVERROR(EINVAL); } } @@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or neither must be specified\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { @@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_max_rate && @@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->bit_rate * (int64_t)avctx->time_base.num > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (!s->fixed_qscale && @@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P && s->codec_id != AV_CODEC_ID_FLV1) { av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decision\n"); -return -1; +return AVERROR(EINVAL); } if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->max_b_frames&& @@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->max_b_frames < 0) { av_log(avctx, AV_LOG_ERROR, "max b frames must be 0 or positive for mpegvideo based encoders\n"); -return -1; +return AVERROR(EINVAL); } if ((s->codec_id == AV_CODEC_ID_MPEG4 || @@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS (avctx->width > 2048 || avctx->height > 1152 )) { av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions above 2048x1152\n"); -return -1; +return AVERROR(EINVAL); } if ((s->codec_id == AV_CODEC_ID_H263 || s->codec_id == AV_CODEC_ID_H263P) && ((avctx->width &3) || (avctx->height&3) )) { av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO && (avctx->width > 4095 || avctx->height > 4095 )) { av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions above 4095x4095\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && (avctx->width > 16383 || avctx->height > 16383 )) { av_log(avctx, AV_LOG_ERROR, "MPEG-2 does not support resolutions above 16383x16383\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_RV10 && @@ -597,13 +597,13 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id == AV_CODEC_I
Re: [FFmpeg-devel] [PATCH v3 2/5] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
On 5/7/2020 10:22 AM, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/mpegvideo_enc.c | 85 > +++--- > 1 file changed, 43 insertions(+), 42 deletions(-) > > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c > index e1fd92c..bb7ac88 100644 > --- a/libavcodec/mpegvideo_enc.c > +++ b/libavcodec/mpegvideo_enc.c > @@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > avctx->pix_fmt != AV_PIX_FMT_YUV422P) { > av_log(avctx, AV_LOG_ERROR, > "only YUV420 and YUV422 are supported\n"); > -return -1; > +return AVERROR(EINVAL); > } > break; > case AV_CODEC_ID_MJPEG: > @@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > > if (!format_supported) { > av_log(avctx, AV_LOG_ERROR, "colorspace not supported in > jpeg\n"); > -return -1; > +return AVERROR(EINVAL); > } > break; > default: > if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { > av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); > -return -1; > +return AVERROR(EINVAL); > } > } > > @@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { > av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or > neither must be specified\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { > @@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > > if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { > av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { > av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (avctx->rc_max_rate && > @@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > avctx->bit_rate * (int64_t)avctx->time_base.num > > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { > av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (!s->fixed_qscale && > @@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS > s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P > && > s->codec_id != AV_CODEC_ID_FLV1) { > av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { > av_log(avctx, AV_LOG_ERROR, > "OBMC is only supported with simple mb decision\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { > av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->max_b_frames&& > @@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > s->codec_id != AV_CODEC_ID_MPEG1VIDEO && > s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { > av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); > -return -1; > +return AVERROR(EINVAL); > } > if (s->max_b_frames < 0) { > av_log(avctx, AV_LOG_ERROR, > "max b frames must be 0 or positive for mpegvideo based > encoders\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if ((s->codec_id == AV_CODEC_ID_MPEG4 || > @@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS > (avctx->width > 2048 || > avctx->height > 1152 )) { > av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions > above 2048x1152\n"); > -return -1; > +return AVERROR(EINVAL); > } > if ((s->codec_id == AV_CODEC_ID_H263 || > s->codec_id == AV_CODEC_ID_H263P) && > ((avctx->width &3) || > (avctx->height&3) )) { > av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO && > (avctx->width > 4095 || > avctx->height > 4095 )) { > av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions > above 4095x4095\n"); > -return -1; > +return AVERROR(EINVAL); > } > > if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && > (avctx->width > 16383
[FFmpeg-devel] [PATCH v4 2/5] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo_enc.c | 85 +++--- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e1fd92c..50ae57e 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->pix_fmt != AV_PIX_FMT_YUV422P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 and YUV422 are supported\n"); -return -1; +return AVERROR(EINVAL); } break; case AV_CODEC_ID_MJPEG: @@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if (!format_supported) { av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n"); -return -1; +return AVERROR(EINVAL); } break; default: if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); -return -1; +return AVERROR(EINVAL); } } @@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or neither must be specified\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { @@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (avctx->rc_max_rate && @@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->bit_rate * (int64_t)avctx->time_base.num > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); -return -1; +return AVERROR(EINVAL); } if (!s->fixed_qscale && @@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P && s->codec_id != AV_CODEC_ID_FLV1) { av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decision\n"); -return -1; +return AVERROR(EINVAL); } if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->max_b_frames&& @@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); -return -1; +return AVERROR(EINVAL); } if (s->max_b_frames < 0) { av_log(avctx, AV_LOG_ERROR, "max b frames must be 0 or positive for mpegvideo based encoders\n"); -return -1; +return AVERROR(EINVAL); } if ((s->codec_id == AV_CODEC_ID_MPEG4 || @@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS (avctx->width > 2048 || avctx->height > 1152 )) { av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions above 2048x1152\n"); -return -1; +return AVERROR(EINVAL); } if ((s->codec_id == AV_CODEC_ID_H263 || s->codec_id == AV_CODEC_ID_H263P) && ((avctx->width &3) || (avctx->height&3) )) { av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO && (avctx->width > 4095 || avctx->height > 4095 )) { av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions above 4095x4095\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && (avctx->width > 16383 || avctx->height > 16383 )) { av_log(avctx, AV_LOG_ERROR, "MPEG-2 does not support resolutions above 16383x16383\n"); -return -1; +return AVERROR(EINVAL); } if (s->codec_id == AV_CODEC_ID_RV10 && @@ -597,13 +597,13 @@ FF_ENABLE_DEPRECATION_WARNINGS s->codec_id == AV_CODEC_I
Re: [FFmpeg-devel] [PATCH v3 2/5] avcodec/mpegvideo_enc: return more specific error codes for ff_mpv_encode_init()
On Thu, May 07, 2020 at 10:29:50AM -0300, James Almer wrote: > On 5/7/2020 10:22 AM, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/mpegvideo_enc.c | 85 > > +++--- > > 1 file changed, 43 insertions(+), 42 deletions(-) > > > > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c > > index e1fd92c..bb7ac88 100644 > > --- a/libavcodec/mpegvideo_enc.c > > +++ b/libavcodec/mpegvideo_enc.c > > @@ -298,7 +298,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > > avctx->pix_fmt != AV_PIX_FMT_YUV422P) { > > av_log(avctx, AV_LOG_ERROR, > > "only YUV420 and YUV422 are supported\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > break; > > case AV_CODEC_ID_MJPEG: > > @@ -322,13 +322,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) > > > > if (!format_supported) { > > av_log(avctx, AV_LOG_ERROR, "colorspace not supported in > > jpeg\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > break; > > default: > > if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { > > av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > } > > > > @@ -456,7 +456,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > > > if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { > > av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate > > or neither must be specified\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { > > @@ -466,12 +466,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > > > > if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { > > av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { > > av_log(avctx, AV_LOG_ERROR, "bitrate above max bitrate\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (avctx->rc_max_rate && > > @@ -485,7 +485,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > avctx->bit_rate * (int64_t)avctx->time_base.num > > > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { > > av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (!s->fixed_qscale && > > @@ -511,18 +511,18 @@ FF_ENABLE_DEPRECATION_WARNINGS > > s->codec_id != AV_CODEC_ID_H263 && s->codec_id != > > AV_CODEC_ID_H263P && > > s->codec_id != AV_CODEC_ID_FLV1) { > > av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { > > av_log(avctx, AV_LOG_ERROR, > > "OBMC is only supported with simple mb decision\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { > > av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->max_b_frames&& > > @@ -530,12 +530,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > > s->codec_id != AV_CODEC_ID_MPEG1VIDEO && > > s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { > > av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > if (s->max_b_frames < 0) { > > av_log(avctx, AV_LOG_ERROR, > > "max b frames must be 0 or positive for mpegvideo based > > encoders\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if ((s->codec_id == AV_CODEC_ID_MPEG4 || > > @@ -555,28 +555,28 @@ FF_ENABLE_DEPRECATION_WARNINGS > > (avctx->width > 2048 || > > avctx->height > 1152 )) { > > av_log(avctx, AV_LOG_ERROR, "H.263 does not support resolutions > > above 2048x1152\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > if ((s->codec_id == AV_CODEC_ID_H263 || > > s->codec_id == AV_CODEC_ID_H263P) && > > ((avctx->width &3) || > > (avctx->height&3) )) { > > av_log(avctx, AV_LOG_ERROR, "w/h must be a multiple of 4\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO && > >
Re: [FFmpeg-devel] [PATCH v3 1/3] avcodec/libx265: Fix Uninitialized scalar variable
On Sat, Apr 18, 2020 at 12:52:47PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > return error if unknown picture type encountered > > Fixes CID 1457234 > Signed-off-by: Limin Wang > > Signed-off-by: Limin Wang > --- > haven't merge yet, so rebase to the git master > > libavcodec/libx265.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c > index e42c7b4..573ecc8 100644 > --- a/libavcodec/libx265.c > +++ b/libavcodec/libx265.c > @@ -550,6 +550,9 @@ static int libx265_encode_frame(AVCodecContext *avctx, > AVPacket *pkt, > case X265_TYPE_BREF: > pict_type = AV_PICTURE_TYPE_B; > break; > +default: > +av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered.\n"); > +return AVERROR_EXTERNAL; > } will apply the patch set tomorrow if no comments. > > #if FF_API_CODED_FRAME > -- > 2.9.5 > -- Thanks, Limin Wang ___ 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 11/12] avformat/nutenc: Don't segfault when chapters are added during muxing
On Tue, May 05, 2020 at 04:16:56PM +0200, Andreas Rheinhardt wrote: > When writing the header, the NUT muxer allocates an array with as many > entries as there are chapters containing information about the used > timebase. This information is used when writing the headers and also > when resending the headers (as the NUT muxer does from time to time). > > When the NUT muxer writes or resends the headers, it simply presumes > that there are enough entries in its array for each chapter in the > AVFormatContext. Yet users are allowed to add chapters during the muxing > process, so this presumption is wrong and may lead to segfaults. > > So explicitly store the number of entries of the chapter array and refer > to this number whenever headers are written. > > Signed-off-by: Andreas Rheinhardt > --- > This patch presumes that the user may not change or remove the chapters > available during writing the header (if there were chapters available > when writing the header at all). I hope this is ok. > > libavformat/nut.h| 1 + > libavformat/nutenc.c | 3 ++- > 2 files changed, 3 insertions(+), 1 deletion(-) how do i apply this (for testing) ? on its own it fails and it seems the previous patchset doesnt like applying anymore either > > diff --git a/libavformat/nut.h b/libavformat/nut.h > index a4409ee23d..52225fed93 100644 > --- a/libavformat/nut.h > +++ b/libavformat/nut.h > @@ -115,6 +115,7 @@ typedef struct NUTContext { > int flags; > int version; // version currently in use > int minor_version; > +unsigned nb_chapters; > } NUTContext; > > extern const AVCodecTag ff_nut_subtitle_tags[]; > diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c > index 5071278835..2d35c44b79 100644 > --- a/libavformat/nutenc.c > +++ b/libavformat/nutenc.c > @@ -675,7 +675,7 @@ static int write_headers(AVFormatContext *avctx, > AVIOContext *bc) > goto fail; > } > > -for (i = 0; i < nut->avf->nb_chapters; i++) { > +for (i = 0; i < nut->nb_chapters; i++) { > write_chapter(nut, dyn_bc, i, prelude, &prelude_size); also if i read this correctly, this would not write all chapters. That seems not ideal Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt complain" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" 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] subtitles filter and -ss
Thanks for the tip Nicolas. Well, -copyts works fine when you're re-encoding at full speed. But when used in combination with -re, as shown below, it prevents the input from being "fast-seeked" to the desired position. So, it's kind of useless. ffmpeg -re -copyts -ss 20:10.00 -i input.mp4 -vf subtitles=subs.srt \ -c:v libx264 crf 25 -c:a aac -ab 160k \ -strict experimental \ -f flv $RTMP_URL I'm not intimate enough with the code to tell if that's a bug or an inherent limitation of -copyts. OTOH, the shift option added to the subtitles filter with the patch does not prevent fast-seeking. And you also have the added benefit of adjusting subtitles delay without having to rewrite them. Regards, Manolis On Mon, 4 May 2020 at 11:38, Nicolas George wrote: > Manolis Stamatogiannakis (12020-05-03): > > I've noticed what appears to be a bug/missing feature in the subtitles > > filter: when "-ss" is used for the input, it is not applied to the > > subtitles stream. E.g., for the following command line, the video > playback > > will start on 20:10, but the subtitles will start from 00:00. > > You can use -copyts to keep the timestamps of the video matching with > the subtitles. > > Regards, > > -- > Nicolas George > ___ > 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 12/12] avformat/nutenc: Fix repeating headers
On Tue, May 05, 2020 at 04:16:57PM +0200, Andreas Rheinhardt wrote: > Commit 14b3f9961f3cf9173c43c936eb0cfb5a35fb8419 introduced header > repetition (used to improve resilience) in the NUT muxer; a variable > header_count was added for this to the NUTContext. It contained the > number of times the header has already been sent. > > Yet a few months later a712d725c0d466cc3672d626883319ef828ca8d6 and > 3b4f69ae8ceac45dd815d26e17d83a7dda4c4057 were merged which added support > for header elision in the NUT muxer resp. demuxer. Both of these commits > used the header_count variable to denote the number of stored headers. > This effectively initialized header_count to seven; it was still > incremented when writing a header (in particular, it was eight after > writing the first header at the beginning of the file), yet given that > it started from such a high level the first repeated header would only > be inserted after 16TiB. > > (The NUTContext supports up to 128 stored headers in order to satisfy > the needs of the demuxer (which shares this context with the muxer). > If the muxer had its own context that only contained seven entries for > headers, then this would have been very dangerous, because after writing > the initial header the number of actual stored headers and header_count > differ.) > > This commit fixes this by separating the two variables. The number of > written headers is now stored in header_written. > > Given that NUT output is used in a large number of FATE tests that have > nothing to do with NUT (like the filter-pixdesc tests that use NUT with > the md5 output protocol) a large number of tests had to be updated. The > only difference is that now repeated headers are written when writing > the trailer. Notice that the part of the tests that actually test the > file's contents did not need to be modified as seen with the acodec-pcm > tests. > > Signed-off-by: Andreas Rheinhardt > --- > This commit is simply about fixing the regression caused by a712d725 and > restoring the previous behaviour. In particular, it potentially repeats > the header twice when writing the trailer, although I don't know why. if there is damage to one of 2 headers it is not neccessarily always clear what is damaged, with 3 one can simply take the majority. > I am also unsure why the size difference between successive headers > grows exponentially. I think i dont understand what you say here. The size of each header should not grow exponentially relativly to the previous > > And maybe we should stop using NUT in all these tests that have nothing > to do with NUT. One advantage of NUT is that we can extend it whenever we need. So theres never a feature we couldnt test with nut. That makes nut a simple choice to use universally when the container is not the article of the test itself thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire 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 11/12] avformat/nutenc: Don't segfault when chapters are added during muxing
Michael Niedermayer: > On Tue, May 05, 2020 at 04:16:56PM +0200, Andreas Rheinhardt wrote: >> When writing the header, the NUT muxer allocates an array with as many >> entries as there are chapters containing information about the used >> timebase. This information is used when writing the headers and also >> when resending the headers (as the NUT muxer does from time to time). >> >> When the NUT muxer writes or resends the headers, it simply presumes >> that there are enough entries in its array for each chapter in the >> AVFormatContext. Yet users are allowed to add chapters during the muxing >> process, so this presumption is wrong and may lead to segfaults. >> >> So explicitly store the number of entries of the chapter array and refer >> to this number whenever headers are written. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> This patch presumes that the user may not change or remove the chapters >> available during writing the header (if there were chapters available >> when writing the header at all). I hope this is ok. >> >> libavformat/nut.h| 1 + >> libavformat/nutenc.c | 3 ++- >> 2 files changed, 3 insertions(+), 1 deletion(-) > > how do i apply this (for testing) ? When you test this, you should be aware that the first time the header is repeated is after 16 TiB of output (see patch #12 for the reason), so you should better change the following line in nut_write_packet() to reduce said interval: if (1LL << (20 + 3 * nut->header_count) <= avio_tell(bc)) > on its own it fails and it seems the previous patchset doesnt like applying > anymore either > I have already applied patches 1-4 + 9 (that you said were ok) from this patchset. Patches 5-8 and 10-11 apply cleanly on top of master. Did you try to also apply the patches that have already been merged? (Patch #12 does not apply cleanly any more, because of the changes to the ref files in b4967fc71c63eae8cd96f9c46cd3e1fbd705bbf9. Furthermore my patch as sent only updated a subset of fate-tests, because my build was not configured with enable-gpl. I already fixed this. Normally I'd resend the mail, but given its huge size I'd like to avoid that this time. Should I send it?) > >> >> diff --git a/libavformat/nut.h b/libavformat/nut.h >> index a4409ee23d..52225fed93 100644 >> --- a/libavformat/nut.h >> +++ b/libavformat/nut.h >> @@ -115,6 +115,7 @@ typedef struct NUTContext { >> int flags; >> int version; // version currently in use >> int minor_version; >> +unsigned nb_chapters; >> } NUTContext; >> >> extern const AVCodecTag ff_nut_subtitle_tags[]; >> diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c >> index 5071278835..2d35c44b79 100644 >> --- a/libavformat/nutenc.c >> +++ b/libavformat/nutenc.c >> @@ -675,7 +675,7 @@ static int write_headers(AVFormatContext *avctx, >> AVIOContext *bc) >> goto fail; >> } >> >> -for (i = 0; i < nut->avf->nb_chapters; i++) { >> +for (i = 0; i < nut->nb_chapters; i++) { >> write_chapter(nut, dyn_bc, i, prelude, &prelude_size); > > also if i read this correctly, this would not write all chapters. > That seems not ideal It's indeed not ideal; it is designed to fix a potential segfault, not to add functionality. (Without this patch patch #12 would run into this bug more often.) I don't know NUT very well, but I see two ways how this could be implemented: 1. One adds the timebases of these chapters to the arrays of timebases that already exist and writes the chapters with their timebases. This would involve moving code from nut_write_header() to write_headers(). I don't know whether adding a new timebase mid-stream is even allowed by the spec. 2. One writes the chapters with the best timebase available for them, even when it is not an exact match. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Shuffle avio_seek
On Thu, May 07, 2020 at 02:09:43PM +0200, Anton Khirnov wrote: > Quoting Michael Niedermayer (2020-05-07 12:38:26) > > This avoids accessing an old, no longer valid buffer. > > Fixes: out of array access > > Fixes: crash_audio-2020 > > > > Found-by: le wu > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/mpegts.c | 7 --- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > > index 0833d62ea5..a065c61c40 100644 > > --- a/libavformat/mpegts.c > > +++ b/libavformat/mpegts.c > > @@ -2881,15 +2881,16 @@ static int mpegts_resync(AVFormatContext *s, int > > seekback, const uint8_t *curren > > AVIOContext *pb = s->pb; > > int c, i; > > uint64_t pos = avio_tell(pb); > > - > > -avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR); > > +int64_t back = FFMIN(seekback, pos); > > > > //Special case for files like 01c56b0dc1.ts > > if (current_packet[0] == 0x80 && current_packet[12] == 0x47) { > > -avio_seek(pb, 12, SEEK_CUR); > > +avio_seek(pb, 12 - back, SEEK_CUR); > > return 0; > > } > > > > +avio_seek(pb, -back, SEEK_CUR); > > + > > This seems pretty non-obvious - why would ordering seeks in a specific > way result in invalid memorry access? because current_packet in one case points to the avio internal buffer and doing any "state changing" avio could change that buffer. so all accesses to the buffer must happen before any avio seeks this issue in fact was not reproducable in master but some release branches it just seems master is affected too. For reproduction a custom http server may be required, i did had some initial difficulty with reproduction even on the affected release branch ... thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Elect your leaders based on what they did after the last election, not based on what they say before an election. 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 12/12] avformat/nutenc: Fix repeating headers
Michael Niedermayer: > On Tue, May 05, 2020 at 04:16:57PM +0200, Andreas Rheinhardt wrote: >> Commit 14b3f9961f3cf9173c43c936eb0cfb5a35fb8419 introduced header >> repetition (used to improve resilience) in the NUT muxer; a variable >> header_count was added for this to the NUTContext. It contained the >> number of times the header has already been sent. >> >> Yet a few months later a712d725c0d466cc3672d626883319ef828ca8d6 and >> 3b4f69ae8ceac45dd815d26e17d83a7dda4c4057 were merged which added support >> for header elision in the NUT muxer resp. demuxer. Both of these commits >> used the header_count variable to denote the number of stored headers. >> This effectively initialized header_count to seven; it was still >> incremented when writing a header (in particular, it was eight after >> writing the first header at the beginning of the file), yet given that >> it started from such a high level the first repeated header would only >> be inserted after 16TiB. >> >> (The NUTContext supports up to 128 stored headers in order to satisfy >> the needs of the demuxer (which shares this context with the muxer). >> If the muxer had its own context that only contained seven entries for >> headers, then this would have been very dangerous, because after writing >> the initial header the number of actual stored headers and header_count >> differ.) >> >> This commit fixes this by separating the two variables. The number of >> written headers is now stored in header_written. >> >> Given that NUT output is used in a large number of FATE tests that have >> nothing to do with NUT (like the filter-pixdesc tests that use NUT with >> the md5 output protocol) a large number of tests had to be updated. The >> only difference is that now repeated headers are written when writing >> the trailer. Notice that the part of the tests that actually test the >> file's contents did not need to be modified as seen with the acodec-pcm >> tests. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> This commit is simply about fixing the regression caused by a712d725 and > >> restoring the previous behaviour. In particular, it potentially repeats >> the header twice when writing the trailer, although I don't know why. > > if there is damage to one of 2 headers it is not neccessarily always clear > what is damaged, with 3 one can simply take the majority. > Makes sense. > >> I am also unsure why the size difference between successive headers >> grows exponentially. > > I think i dont understand what you say here. > The size of each header should not grow exponentially relativly to the > previous > I did not mean the size of the header, but the position/offsets of the headers. I specifically meant this line: if (1LL << (20 + 3 * nut->header_count) <= avio_tell(bc)) which in its current form that the first repeated header will be written after 16 TiB, then another one after 128 TiB (i.e. after further 112 TiB) and so on. > >> >> And maybe we should stop using NUT in all these tests that have nothing >> to do with NUT. > > One advantage of NUT is that we can extend it whenever we need. So theres > never a feature we couldnt test with nut. > That makes nut a simple choice to use universally when the container is > not the article of the test itself > Maybe a hash muxer would be better suited for this; but unfortunately none of the current versions seem to be suited for the task: The framehash/crc muxers generate too much output; the other muxers ignore too much of the input (they only take the packet's data into account, ignoring extradata, side data, timestamps etc.). - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [WIP] XComposite window capture demuxer (Linux)
Hi FFMPEG devel, I have been writing a simple XComposite window capture demuxer, heavily inspired from x11grab sources and OBS Window capture logic/code. I would like to give back to the community and share the sources; before I would formally submit for a review/patch, I would really appreciate if someone could have a high level pass at the code (it's relatively simple actually) and point out any major issues/problems/... The code is available as part of a simple test application on github, at: https://github.com/Emanem/replayer/blob/master/src/xcompgrab.c Being the author of the code I would be happy to re-license it to be used in ffmpeg/libav* mainline once I get the OK from you. In order to compile/execute this code, one needs the following dev packages: libav*-dev, libx11-dev, libxcomposite-dev, OpenGL headers/libs. Libraries to be linked are: -lavcodec -lavformat -lavdevice -lavutil -lswscale -lX11 -lXcomposite -lGL I've tested it and it's working fine on both AMD and Nvidia hardware. Let me know if this is of interest, otherwise no worries and thanks again for the fantastic library/software. Emanuele ___ 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] libavutil: add clean aperture (CLAP) side data.
Neil Birkbeck: > On Tue, Apr 28, 2020 at 3:18 AM Nicolas George wrote: > >> Andreas Rheinhardt (12020-04-28): >>> That's expected. The patch provided only provides the structure in which >>> the values are intended to be exported; it does not add any demuxing or >>> muxing capabilities for mov or mkv (as you can see from the fact that >>> none of these (de)muxers have been changed in the patch). >> >> Which is something I intended to comment on: adding code without users >> is rarely a good idea. I suggest we do not commit until at least one >> demuxer use it, preferably at least two. Otherwise, we may realize that >> “oh crap, it doesn't work” because of a tiny unforeseen detail. > > > Thanks for the feedback. I also have patches for the demux (MOV/MKV) and > mux (MOV/MKV). > > As there is still the alternative of using the fields in the > AVCodecParameters/AVCodecContext, my intention was to keep the first patch > small to resolve discussion on that point. > > I've included the patches, if you'd like to try test it, Kieren. I see on > your test file that there may be some slight rounding error making output > crop 704 not 703 (MKV file ends up with pixel_crop_{left,right} = 8). > > /ffprobe ../testdata/clap.mov 2>&1 | grep -A1 "Side" > Side data: > Clean aperture:[width 41472/59 height:576/1 h_offset:0/1 v_offset:0/1] > ./ffmpeg -i ../testdata/clap.mov -vcodec copy -acodec copy /tmp/clap.mkv > ./ffprobe /tmp/clap.mkv 2>&1 | grep -A1 "Side" > Side data: > Clean aperture:[width 704/1 height:576/1 h_offset:0/1 v_offset:0/1] > > > > Write out stream-level AVCleanAperture side data in the muxer. You should separate the mov and Matroska patches. > > Signed-off-by: Neil Birkbeck > --- > libavformat/matroskaenc.c | 37 + > libavformat/movenc.c | 28 > 2 files changed, 57 insertions(+), 8 deletions(-) > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index 784973a951..19ff29853e 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -901,6 +901,38 @@ static int mkv_write_video_color(AVIOContext *pb, const > AVCodecParameters *par, > return 0; > } > > +static int mkv_write_video_crop(AVIOContext *pb, AVCodecParameters *par, > AVStream *st) > +{ > +int cropb = 0, cropt = 0, cropl = 0, cropr = 0; > +double width, height, h_offset, v_offset; > +int side_data_size = 0; > +const AVCleanAperture *clap = > +(const AVCleanAperture *)av_stream_get_side_data( > +st, AV_PKT_DATA_CLEAN_APERTURE, &side_data_size); > +if (!clap) > +return 0; > + > +width = av_q2d(clap->width); > +height = av_q2d(clap->height); > +h_offset = av_q2d(clap->horizontal_offset); > +v_offset = av_q2d(clap->vertical_offset); > +cropb = (int)(par->height - (par->height / 2. + v_offset + height / 2)); > +cropt = (int)(par->height / 2. + v_offset - height / 2); > +cropr = (int)(par->width - (par->width / 2. + h_offset + width / 2)); > +cropl = (int)(par->width / 2. + h_offset - width / 2); > +cropb = FFMAX(cropb, 0); > +cropt = FFMAX(cropt, 0); > +cropr = FFMAX(cropr, 0); > +cropl = FFMAX(cropl, 0); > +if (!cropr && !cropl && !cropt && !cropb) > +return 0; > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPL, cropl); > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPR, cropr); > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPB, cropb); > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPT, cropt); There is no reason to write all four elements when only some of them are different from zero. > +return 0; > +} > + > static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, >const AVStream *st) > { > @@ -1287,6 +1319,11 @@ static int mkv_write_track(AVFormatContext *s, > MatroskaMuxContext *mkv, > } else if (mkv->mode != MODE_WEBM) > put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYUNIT, > MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN); > > +// Write out pixel crop > +ret = mkv_write_video_crop(pb, par, st); > +if (ret < 0) > +return ret; This is the wrong place for this: It needs to be performed before we write the display dimensions and you need to return the cropped width and height via pointer arguments, so that the code doing display dimensions (which needs to be updated) knows about the cropping. This is necessary, because cropping is supposed to happen before scaling: If the code for writing DisplayWidth/Height didn't know about the real dimensions to scale, it would write the DisplayWidth/Height values that are appropriate for a video with the given pixel aspect ratio and the uncropped pixel dimensions. We should btw error out if someone sends stereo 3d data that implies that a dimension is doubled if cropping is intended to be applied in the same dimension, as this scena
[FFmpeg-devel] [PATCH] libavcodec: v4l2m2m: allow lower minimum buffer values
There is no reason to enforce a high minimum. In the context of streaming only a few output buffers and capture buffers are even needed for continuous playback. This also helps alleviate memory pressure when decoding 4K media. --- libavcodec/v4l2_m2m.h | 2 +- libavcodec/v4l2_m2m_dec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h index 61cb919771..feeb162812 100644 --- a/libavcodec/v4l2_m2m.h +++ b/libavcodec/v4l2_m2m.h @@ -38,7 +38,7 @@ #define V4L_M2M_DEFAULT_OPTS \ { "num_output_buffers", "Number of buffers in the output context",\ -OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 6, INT_MAX, FLAGS } +OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 2, INT_MAX, FLAGS } typedef struct V4L2m2mContext { char devname[PATH_MAX]; diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index c6b865fde8..b9725be377 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -262,7 +262,7 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) static const AVOption options[] = { V4L_M2M_DEFAULT_OPTS, { "num_capture_buffers", "Number of buffers in the capture context", -OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 20, INT_MAX, FLAGS }, +OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 2, INT_MAX, FLAGS }, { NULL}, }; -- 2.24.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 v2 4/5] avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()
On Thu, 7 May 2020, lance.lmw...@gmail.com wrote: From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 22cab28..b5ddb1b 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -889,7 +889,7 @@ static void clear_context(MpegEncContext *s) */ av_cold int ff_mpv_common_init(MpegEncContext *s) { -int i, ret; +int i, ret = AVERROR(ENOMEM); This initialization is unnecessary here, you will overwrite ret later. int nb_slices = (HAVE_THREADS && s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; @@ -907,7 +907,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { av_log(s->avctx, AV_LOG_ERROR, "decoding to AV_PIX_FMT_NONE is not supported.\n"); -return -1; +return AVERROR(EINVAL); } if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) { @@ -923,7 +923,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if ((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) -return -1; +return AVERROR(EINVAL); dct_init(s); @@ -954,7 +954,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (!s->new_picture.f) goto fail; -if (init_context_frame(s)) +if ((ret = init_context_frame(s))) goto fail; s->parse_context.state = -1; @@ -971,7 +971,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (!s->thread_context[i]) goto fail; } -if (init_duplicate_context(s->thread_context[i]) < 0) +if ((ret = init_duplicate_context(s->thread_context[i])) < 0) goto fail; s->thread_context[i]->start_mb_y = (s->mb_height * (i) + nb_slices / 2) / nb_slices; @@ -979,7 +979,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; } } else { -if (init_duplicate_context(s) < 0) +if ((ret = init_duplicate_context(s)) < 0) goto fail; s->start_mb_y = 0; s->end_mb_y = s->mb_height; @@ -990,7 +990,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) return 0; fail: ff_mpv_common_end(s); -return -1; +return ret Not all goto fail set ret. I think it is cleaner if you add a new label "fail_nomem" before the fail label and set ret to ENOMEM there, and use that label for ENOMEM cases. 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 v2 5/5] avcodec/mpegvideo: return more specific error codes for init_duplicate_context()
On Thu, 7 May 2020, lance.lmw...@gmail.com wrote: From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index b5ddb1b..8a74a45 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -359,7 +359,7 @@ static int init_duplicate_context(MpegEncContext *s) int y_size = s->b8_stride * (2 * s->mb_height + 1); int c_size = s->mb_stride * (s->mb_height + 1); int yc_size = y_size + 2 * c_size; -int i; +int i, ret = AVERROR(ENOMEM); ret is uncecessary. if (s->mb_height & 1) yc_size += 2*s->b8_stride + 2*s->mb_stride; @@ -408,7 +408,7 @@ static int init_duplicate_context(MpegEncContext *s) return 0; fail: -return -1; // free() through ff_mpv_common_end() +return ret; // free() through ff_mpv_common_end() Simply return AVERROR(ENOMEM) because all failures are ENOMEM-s. } static void free_duplicate_context(MpegEncContext *s) -- 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 v4 4/8] avformat/mux: add proper support for full N:M bitstream filtering
On Tue, 5 May 2020, Marton Balint wrote: On Tue, 5 May 2020, Andreas Rheinhardt wrote: Marton Balint: On Tue, 5 May 2020, Andreas Rheinhardt wrote: Marton Balint: Previously only 1:1 bitstream filters were supported, the end of the stream was not signalled to the bitstream filters and time base changes were ignored. This change also allows muxers to set up bitstream filters regardless of the autobsf flag during write_header instead of during check_bitstream and those bitstream filters will always be executed. Ignoring the autobsf flag is not ok IMO. The muxer should not add a bsf when the user explicitly didn't want this. The user should not be allowed to create broken files, and the only way to achieve that is to force the BSF. I don't see a use case for disabling BSF either for MXFenc of GXFenc. (in fact, from the top of my head I can't see a use case for disabling automatically inserted BSF-s in other muxers). When automatic bitstream filtering was introduced in 1f9139b07b8a896b62c1f28f3d04acac33978c0d, writing the header of every muxer that potentially might include a bsf automatically (as indicated by the existence of the check_bitstream()-function) was delayed until the first packet would be written. This meant that there was a high probability of having a packet for the relevant stream when using the interleaved codepath. In particular, this meant that the Matroska muxer now received proper extradata for AAC when writing the header even before it received any packet with side data containing potential extradata at all. The reason was that the aac_adtstoasc bsf has simply overwritten the output extradata when dealing with the first packet (that was the old bsf API without init functions; when the new bsf API was merged, the merge commit (not the original commit) propagated the API violating behaviour). 1f6d7eb47070afc4394348721cd149f940ad2386 added the autobsf flag because of this delay: After all, the delay existed as soon as the AVOutputFormat had a check_bitstream function, even when no stream had a codec for which the check_bitstream function would add a bsf at all. As time passed, the API-violating behaviour of aac_adtstoasc was fixed and d6d605eb05c3ca32f591016c345eb2ad9e81c554 stopped delaying writing the header. The very same patchset containing said commit also contained a patch to deprecate AVFMT_FLAG_AUTO_BSF [1]. It was not applied due to concerns what happens when the bsf is not available. (For the record, ff_stream_add_bitstream_filter() will error out if a bsf is not available and the packet discarded. If the caller sends another packet for this stream and a bsf that should be added isn't available the packet will be rejected as well and so on.) The fact that one is forced to include certain automatically inserted bitstream filters even when one knows that one will only use them in scenarios where they merely passthrough the packets is certainly a downside of eliminating this flag. But now that I have reread the history I am nevertheless in favour of deprecation. Wow, thanks for checking this. But if we are moving in the direction of deprecation, then I'd rather not add the extra check to ff_stream_add_bitstream_filter because it will be removed later anyway. Also when I tried to add that, there was a fate failure caused by the segment muxer setting the -autobsf flag but calling the muxer's check_bitstream function directly. Or should I add create a patch which simply removes the -autobsf additional options from segment.c? So considering that autobsf will probably be deprecated anyway can I apply the patch as is? (And finally the series?). Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [WIP] XComposite window capture demuxer (Linux)
On Thu, 7 May 2020, Emanuele Oriani wrote: Hi FFMPEG devel, I have been writing a simple XComposite window capture demuxer, heavily inspired from x11grab sources and OBS Window capture logic/code. Have you compared performance to x11grab for various resolutions and frame rates? Do you have some numbers? Thanks, Marton I would like to give back to the community and share the sources; before I would formally submit for a review/patch, I would really appreciate if someone could have a high level pass at the code (it's relatively simple actually) and point out any major issues/problems/... The code is available as part of a simple test application on github, at: https://github.com/Emanem/replayer/blob/master/src/xcompgrab.c Being the author of the code I would be happy to re-license it to be used in ffmpeg/libav* mainline once I get the OK from you. In order to compile/execute this code, one needs the following dev packages: libav*-dev, libx11-dev, libxcomposite-dev, OpenGL headers/libs. Libraries to be linked are: -lavcodec -lavformat -lavdevice -lavutil -lswscale -lX11 -lXcomposite -lGL I've tested it and it's working fine on both AMD and Nvidia hardware. Let me know if this is of interest, otherwise no worries and thanks again for the fantastic library/software. Emanuele ___ 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 4/8] avformat/mux: add proper support for full N:M bitstream filtering
Marton Balint: > > > On Tue, 5 May 2020, Marton Balint wrote: > >> >> >> On Tue, 5 May 2020, Andreas Rheinhardt wrote: >> >>> Marton Balint: On Tue, 5 May 2020, Andreas Rheinhardt wrote: > Marton Balint: >> Previously only 1:1 bitstream filters were supported, the end of the >> stream was >> not signalled to the bitstream filters and time base changes were >> ignored. >> >> This change also allows muxers to set up bitstream filters regardless >> of the >> autobsf flag during write_header instead of during check_bitstream >> and those >> bitstream filters will always be executed. > > Ignoring the autobsf flag is not ok IMO. The muxer should not add a > bsf > when the user explicitly didn't want this. > The user should not be allowed to create broken files, and the only way to achieve that is to force the BSF. I don't see a use case for disabling BSF either for MXFenc of GXFenc. (in fact, from the top of my head I can't see a use case for disabling automatically inserted BSF-s in other muxers). >>> When automatic bitstream filtering was introduced in >>> 1f9139b07b8a896b62c1f28f3d04acac33978c0d, writing the header of every >>> muxer that potentially might include a bsf automatically (as indicated >>> by the existence of the check_bitstream()-function) was delayed until >>> the first packet would be written. This meant that there was a high >>> probability of having a packet for the relevant stream when using the >>> interleaved codepath. >>> In particular, this meant that the Matroska muxer now received proper >>> extradata for AAC when writing the header even before it received any >>> packet with side data containing potential extradata at all. The reason >>> was that the aac_adtstoasc bsf has simply overwritten the output >>> extradata when dealing with the first packet (that was the old bsf API >>> without init functions; when the new bsf API was merged, the merge >>> commit (not the original commit) propagated the API violating >>> behaviour). >>> 1f6d7eb47070afc4394348721cd149f940ad2386 added the autobsf flag because >>> of this delay: After all, the delay existed as soon as the >>> AVOutputFormat had a check_bitstream function, even when no stream had a >>> codec for which the check_bitstream function would add a bsf at all. >>> >>> As time passed, the API-violating behaviour of aac_adtstoasc was fixed >>> and d6d605eb05c3ca32f591016c345eb2ad9e81c554 stopped delaying writing >>> the header. The very same patchset containing said commit also contained >>> a patch to deprecate AVFMT_FLAG_AUTO_BSF [1]. It was not applied due to >>> concerns what happens when the bsf is not available. >>> >>> (For the record, ff_stream_add_bitstream_filter() will error out if a >>> bsf is not available and the packet discarded. If the caller sends >>> another packet for this stream and a bsf that should be added isn't >>> available the packet will be rejected as well and so on.) >>> >>> The fact that one is forced to include certain automatically inserted >>> bitstream filters even when one knows that one will only use them in >>> scenarios where they merely passthrough the packets is certainly a >>> downside of eliminating this flag. But now that I have reread the >>> history I am nevertheless in favour of deprecation. >> >> Wow, thanks for checking this. But if we are moving in the direction >> of deprecation, then I'd rather not add the extra check to >> ff_stream_add_bitstream_filter because it will be removed later anyway. >> >> Also when I tried to add that, there was a fate failure caused by the >> segment muxer setting the -autobsf flag but calling the muxer's >> check_bitstream function directly. Or should I add create a patch >> which simply removes the -autobsf additional options from segment.c? > > So considering that autobsf will probably be deprecated anyway can I > apply the patch as is? (And finally the series?). > According to me: yes. But there is one little detail that I just noticed: write_packets_common() has an AVStream parameter and both of its callers (av_write_frame() and av_interleaved_write_frame() essentially pass s->streams[pkt->stream_index] into it, but don't use it themselves. This parameter should be eliminated and replaced by a local variable in write_packets_common(). - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/9] libavutil: add API for exporting video frame quantizers
On Sat, Apr 18, 2020 at 5:02 AM Lynne wrote: > Apr 18, 2020, 11:14 by an...@khirnov.net: > > > From: Juan De León > > > > This is intended to replace the deprecated the AV_FRAME_DATA_QP_TABLE* > > API and extend it to a wider range of codecs. > > > > In the future, it may also be extended to support other encoding > > parameters such as motion vectors. > > > > Additional changes by Anton Khirnov with suggestions > > by Lynne . > > > > Signed-off-by: Juan De León > > Signed-off-by: Michael Niedermayer > > Signed-off-by: Anton Khirnov > > > > API looks good, patchset LGTM. > Any chance to have this patch set applied? Thanks > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thierry Foucu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 14/21] avformat/matroskaenc: Make mkv_write_video_projection() return void
It can't fail since 9c8aa86883f28fc27ca790b290c3be2d347b0d19. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index d16d607269..158193738e 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -915,8 +915,8 @@ static void mkv_write_video_color(AVIOContext *pb, const AVStream *st, put_ebml_binary(pb, MATROSKA_ID_VIDEOCOLOR, colour, colorinfo_size); } -static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, - const AVStream *st) +static void mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, + const AVStream *st) { ebml_master projection; int side_data_size = 0; @@ -927,13 +927,13 @@ static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, &side_data_size); if (!side_data_size) -return 0; +return; if (spherical->projection != AV_SPHERICAL_EQUIRECTANGULAR && spherical->projection != AV_SPHERICAL_EQUIRECTANGULAR_TILE && spherical->projection != AV_SPHERICAL_CUBEMAP) { av_log(s, AV_LOG_WARNING, "Unknown projection type\n"); -return 0; +return; } // Maximally 4 8-byte elements with id-length 2 + 1 byte length field @@ -981,8 +981,6 @@ static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, (double) spherical->roll / (1 << 16)); end_ebml_master(pb, projection); - -return 0; } static void mkv_write_field_order(AVIOContext *pb, int mode, @@ -1306,10 +1304,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, put_ebml_binary(pb, MATROSKA_ID_VIDEOCOLORSPACE, &color_space, sizeof(color_space)); } mkv_write_video_color(pb, st, par); +mkv_write_video_projection(s, pb, st); -ret = mkv_write_video_projection(s, pb, st); -if (ret < 0) -return ret; end_ebml_master(pb, subinfo); break; -- 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] [PATCH 15/21] avformat/matroskaenc: Use av_stream_get_side_data() instead of loop
in mkv_write_stereo_mode(). Also check the size of the AVStereo3D side data. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 158193738e..4bb6a0e0d4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1029,6 +1029,8 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, int ret = 0; const AVDictionaryEntry *tag; MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB; +const AVStereo3D *stereo; +int side_data_size = 0; *h_width = 1; *h_height = 1; @@ -1051,12 +1053,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, } } -// iterate to find the stereo3d side data -for (i = 0; i < st->nb_side_data; i++) { -AVPacketSideData sd = st->side_data[i]; -if (sd.type == AV_PKT_DATA_STEREO3D) { -AVStereo3D *stereo = (AVStereo3D *)sd.data; - +stereo = (const AVStereo3D*)av_stream_get_side_data(st, AV_PKT_DATA_STEREO3D, +&side_data_size); +if (side_data_size >= sizeof(AVStereo3D)) { switch (stereo->type) { case AV_STEREO3D_2D: format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO; @@ -1096,8 +1095,6 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, format++; break; } -break; -} } if (format == MATROSKA_VIDEO_STEREOMODE_TYPE_NB) -- 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] [PATCH 19/21] avformat/matroskaenc: Don't ignore tags of chapters written late
The Matroska muxer writes the Chapters early when chapters were already available when writing the header; in this case any tags pertaining to these chapters get written, too. Yet if no chapters had been supplied before writing the header, Chapters can also be written when writing the trailer if any are supplied. Tags belonging to these chapters were up until now completely ignored. This commit changes this: Writing the tags belonging to chapters has been moved to mkv_write_chapters(). If mkv_write_tags() has not been called yet (i.e. when chapters are written when writing the header), the AVIOContext for writing the ordinary Tags element is used, but not output, as this is left to mkv_write_tags() in order to only write one Tags element. Yet if mkv_write_tags() has already been called, mkv_write_chapters() will output a Tags element of its own which only contains the tags for chapters. When chapters are available initially, the corresponding tags will now be the first tags in the Tags element; but the ordering of tags in Tags is irrelevant anyway. This commit also makes chapter_id_offset local to mkv_write_chapters() as it is used only there and not reused at all. Potentially writing a second Tags element means that the maximum number of SeekHead entries had to be incremented. All the changes to FATE result from the ensuing increase in the amount of space reserved for the SeekHead (21 bytes more). Signed-off-by: Andreas Rheinhardt --- Support for multiple Tags elements will land in the demuxer in https://ffmpeg.org/pipermail/ffmpeg-devel/2020-May/261810.html. libavformat/matroskaenc.c | 70 --- tests/fate/matroska.mak | 2 +- tests/fate/wavpack.mak| 4 +- tests/ref/fate/aac-autobsf-adtstoasc | 4 +- tests/ref/fate/binsub-mksenc | 2 +- tests/ref/fate/matroska-flac-extradata-update | 4 +- tests/ref/fate/rgb24-mkv | 4 +- tests/ref/fate/webm-dash-chapters | 4 +- tests/ref/lavf-fate/av1.mkv | 4 +- tests/ref/lavf/mka| 4 +- tests/ref/lavf/mkv| 4 +- tests/ref/lavf/mkv_attachment | 4 +- tests/ref/seek/lavf-mkv | 44 ++-- 13 files changed, 85 insertions(+), 69 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 9103d0a7be..7251d78d44 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -55,8 +55,8 @@ #include "libavcodec/mpeg4audio.h" /* Level 1 elements we create a SeekHead entry for: - * Info, Tracks, Chapters, Attachments, Tags and Cues */ -#define MAX_SEEKHEAD_ENTRIES 6 + * Info, Tracks, Chapters, Attachments, Tags (potentially twice) and Cues */ +#define MAX_SEEKHEAD_ENTRIES 7 #define IS_SEEKABLE(pb, mkv) (((pb)->seekable & AVIO_SEEKABLE_NORMAL) && \ !(mkv)->is_live) @@ -142,8 +142,8 @@ typedef struct MatroskaMuxContext { unsignednb_attachments; int have_video; -uint32_tchapter_id_offset; int wrote_chapters; +int wrote_tags; int reserve_cues_space; int cluster_size_limit; @@ -1546,6 +1546,8 @@ static int mkv_write_tags(AVFormatContext *s) ebml_master tag, *tagp; int i, ret; +mkv->wrote_tags = 1; + ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL); if (mkv_check_tag(s->metadata, 0)) { @@ -1587,21 +1589,6 @@ static int mkv_write_tags(AVFormatContext *s) } } -if (mkv->mode != MODE_WEBM) { -for (i = 0; i < s->nb_chapters; i++) { -AVChapter *ch = s->chapters[i]; - -if (!mkv_check_tag(ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID)) -continue; - -ret = mkv_write_tag(mkv, ch->metadata, &mkv->tags.bc, NULL, -MATROSKA_ID_TAGTARGETS_CHAPTERUID, -(uint32_t)ch->id + (uint64_t)mkv->chapter_id_offset); -if (ret < 0) -return ret; -} -} - if (mkv->nb_attachments && mkv->mode != MODE_WEBM) { for (i = 0; i < s->nb_streams; i++) { const mkv_track *track = &mkv->tracks[i]; @@ -1630,8 +1617,9 @@ static int mkv_write_tags(AVFormatContext *s) static int mkv_write_chapters(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; -AVIOContext *dyn_cp = NULL, *pb = s->pb; +AVIOContext *dyn_cp = NULL, *dyn_tags = NULL, **tags, *pb = s->pb; ebml_master editionentry; +uint64_t chapter_id_offset = 0; AVRational scale = {1, 1E9}; int i, ret; @@ -1640,7 +1628,7 @@ static int mkv_write_chapters(AVFormatContext *s) for (i = 0; i < s->nb_chapters; i++) if (!s->chapters[i]->id) { -mkv->chapter_id_offset = 1; +cha
[FFmpeg-devel] [PATCH 17/21] avformat/matroskaenc: Allow a custom destination for writing Tags
Up until now, the Matroska muxer writes only one Tags level 1 element and therefore using a certain place to store the dynamic buffer used for writing it was hardcoded; yet the Matroska specifications allow an unlimited amount of Tags elements and we have reason to write a second one: If chapters are provided after writing the header, they are written when writing the trailer; yet the corresponding tags are ignored. This can be fixed by writing them in a second Tags element. Also use a MatroskaMuxContext * instead of an AVFormatContext * as parameter in mkv_write_tag() and mkv_write_tag_targets() as that is all these functions use. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 47 ++- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c888f537fb..fad2c18e2b 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1528,26 +1528,23 @@ static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t) return 0; } -static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid, - uint64_t uid, ebml_master *tag) +static int mkv_write_tag_targets(MatroskaMuxContext *mkv, AVIOContext **pb, + ebml_master *tag, uint32_t elementid, uint64_t uid) { -AVIOContext *pb; -MatroskaMuxContext *mkv = s->priv_data; ebml_master targets; int ret; -if (!mkv->tags.bc) { -ret = start_ebml_master_crc32(&mkv->tags.bc, mkv); +if (!*pb) { +ret = start_ebml_master_crc32(pb, mkv); if (ret < 0) return ret; } -pb = mkv->tags.bc; -*tag= start_ebml_master(pb, MATROSKA_ID_TAG,0); -targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 4 + 1 + 8); +*tag= start_ebml_master(*pb, MATROSKA_ID_TAG,0); +targets = start_ebml_master(*pb, MATROSKA_ID_TAGTARGETS, 4 + 1 + 8); if (elementid) -put_ebml_uid(pb, elementid, uid); -end_ebml_master(pb, targets); +put_ebml_uid(*pb, elementid, uid); +end_ebml_master(*pb, targets); return 0; } @@ -1565,28 +1562,28 @@ static int mkv_check_tag_name(const char *name, uint32_t elementid) av_strcasecmp(name, "mimetype"))); } -static int mkv_write_tag(AVFormatContext *s, const AVDictionary *m, - uint32_t elementid, uint64_t uid, ebml_master *tag) +static int mkv_write_tag(MatroskaMuxContext *mkv, const AVDictionary *m, + AVIOContext **pb, ebml_master *tag, + uint32_t elementid, uint64_t uid) { -MatroskaMuxContext *mkv = s->priv_data; const AVDictionaryEntry *t = NULL; ebml_master tag2; int ret; -ret = mkv_write_tag_targets(s, elementid, uid, tag ? tag : &tag2); +ret = mkv_write_tag_targets(mkv, pb, tag ? tag : &tag2, elementid, uid); if (ret < 0) return ret; while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) { if (mkv_check_tag_name(t->key, elementid)) { -ret = mkv_write_simpletag(mkv->tags.bc, t); +ret = mkv_write_simpletag(*pb, t); if (ret < 0) return ret; } } if (!tag) -end_ebml_master(mkv->tags.bc, tag2); +end_ebml_master(*pb, tag2); return 0; } @@ -1611,7 +1608,7 @@ static int mkv_write_tags(AVFormatContext *s) ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL); if (mkv_check_tag(s->metadata, 0)) { -ret = mkv_write_tag(s, s->metadata, 0, 0, NULL); +ret = mkv_write_tag(mkv, s->metadata, &mkv->tags.bc, NULL, 0, 0); if (ret < 0) return ret; } @@ -1627,8 +1624,8 @@ static int mkv_write_tags(AVFormatContext *s) if (!tagp && !mkv_check_tag(st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID)) continue; -ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, -track->uid, tagp); +ret = mkv_write_tag(mkv, st->metadata, &mkv->tags.bc, tagp, +MATROSKA_ID_TAGTARGETS_TRACKUID, track->uid); if (ret < 0) return ret; @@ -1656,9 +1653,9 @@ static int mkv_write_tags(AVFormatContext *s) if (!mkv_check_tag(ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID)) continue; -ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, -(uint32_t)ch->id + (uint64_t)mkv->chapter_id_offset, -NULL); +ret = mkv_write_tag(mkv, ch->metadata, &mkv->tags.bc, NULL, +MATROSKA_ID_TAGTARGETS_CHAPTERUID, +(uint32_t)ch->id + (uint64_t)mkv->chapter_id_offset); if (ret < 0) return ret; } @@ -1675,8 +
[FFmpeg-devel] [PATCH 20/21] avformat/matroskadec: Export FileDescription as title tag
Each AttachedFile in Matroska can have a FileDescription element that contains a human-friendly name for the attached file; yet this element has been ignored up until now. This commit changes this and exports it as title tag instead (the Matroska muxer mapped the title tag to the AttachedFile element since support for Attachments was added). Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 981fb4bc20..455af9d591 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -259,6 +259,7 @@ typedef struct MatroskaTrack { typedef struct MatroskaAttachment { uint64_t uid; char *filename; +char *description; char *mime; EbmlBin bin; @@ -587,7 +588,7 @@ static EbmlSyntax matroska_attachment[] = { { MATROSKA_ID_FILENAME, EBML_UTF8, 0, offsetof(MatroskaAttachment, filename) }, { MATROSKA_ID_FILEMIMETYPE, EBML_STR, 0, offsetof(MatroskaAttachment, mime) }, { MATROSKA_ID_FILEDATA, EBML_BIN, 0, offsetof(MatroskaAttachment, bin) }, -{ MATROSKA_ID_FILEDESC, EBML_NONE }, +{ MATROSKA_ID_FILEDESC, EBML_UTF8, 0, offsetof(MatroskaAttachment, description) }, CHILD_OF(matroska_attachments) }; @@ -2911,6 +2912,8 @@ static int matroska_read_header(AVFormatContext *s) break; av_dict_set(&st->metadata, "filename", attachments[j].filename, 0); av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0); +if (attachments[j].description) +av_dict_set(&st->metadata, "title", attachments[j].description, 0); st->codecpar->codec_id = AV_CODEC_ID_NONE; for (i = 0; mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) { -- 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] [PATCH 21/21] doc/muxers: Document title tag for attachments
The Matroska muxer has always mapped the title tag to the FileDescription element for attachments streams since support for writing attachments was added in commit c7a63a521b5c165405e3577751d649529d09f0c5. This commit merely documents this fact. Signed-off-by: Andreas Rheinhardt --- doc/muxers.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index abdeaf2b22..c598abbe66 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1314,7 +1314,8 @@ The recognized metadata settings in this muxer are: @table @option @item title -Set title name provided to a single track. +Set title name provided to a single track. This gets mapped to +the FileDescription element for a stream written as attachment. @item language Specify the language of the track in the Matroska languages form. -- 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] [PATCH 16/21] avformat/matroskaenc: Clean up mkv_write_stereo_mode()
Mostly reindentation after the last commit. Also remove a variable that is always zero; move another variable to a more local scope and don't assign a value to a local variable immediately before leaving the function. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 87 +++ 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 4bb6a0e0d4..c888f537fb 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1025,8 +1025,6 @@ static void mkv_write_field_order(AVIOContext *pb, int mode, static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, AVStream *st, int mode, int *h_width, int *h_height) { -int i; -int ret = 0; const AVDictionaryEntry *tag; MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB; const AVStereo3D *stereo; @@ -1039,7 +1037,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, (tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) { int stereo_mode = atoi(tag->value); -for (i=0; ivalue, ff_matroska_video_stereo_mode[i])){ stereo_mode = i; break; @@ -1056,49 +1054,49 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, stereo = (const AVStereo3D*)av_stream_get_side_data(st, AV_PKT_DATA_STEREO3D, &side_data_size); if (side_data_size >= sizeof(AVStereo3D)) { -switch (stereo->type) { -case AV_STEREO3D_2D: -format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO; -break; -case AV_STEREO3D_SIDEBYSIDE: -format = (stereo->flags & AV_STEREO3D_FLAG_INVERT) -? MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT -: MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT; -*h_width = 2; -break; -case AV_STEREO3D_TOPBOTTOM: -format = MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM; -if (stereo->flags & AV_STEREO3D_FLAG_INVERT) -format--; -*h_height = 2; -break; -case AV_STEREO3D_CHECKERBOARD: -format = MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR; -if (stereo->flags & AV_STEREO3D_FLAG_INVERT) -format--; -break; -case AV_STEREO3D_LINES: -format = MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR; -if (stereo->flags & AV_STEREO3D_FLAG_INVERT) -format--; -*h_height = 2; -break; -case AV_STEREO3D_COLUMNS: -format = MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR; -if (stereo->flags & AV_STEREO3D_FLAG_INVERT) -format--; -*h_width = 2; -break; -case AV_STEREO3D_FRAMESEQUENCE: -format = MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR; -if (stereo->flags & AV_STEREO3D_FLAG_INVERT) -format++; -break; -} +switch (stereo->type) { +case AV_STEREO3D_2D: +format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO; +break; +case AV_STEREO3D_SIDEBYSIDE: +format = (stereo->flags & AV_STEREO3D_FLAG_INVERT) + ? MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT + : MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT; +*h_width = 2; +break; +case AV_STEREO3D_TOPBOTTOM: +format = MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM; +if (stereo->flags & AV_STEREO3D_FLAG_INVERT) +format--; +*h_height = 2; +break; +case AV_STEREO3D_CHECKERBOARD: +format = MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR; +if (stereo->flags & AV_STEREO3D_FLAG_INVERT) +format--; +break; +case AV_STEREO3D_LINES: +format = MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR; +if (stereo->flags & AV_STEREO3D_FLAG_INVERT) +format--; +*h_height = 2; +break; +case AV_STEREO3D_COLUMNS: +format = MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR; +if (stereo->flags & AV_STEREO3D_FLAG_INVERT) +format--; +*h_width = 2; +break; +case AV_STEREO3D_FRAMESEQUENCE: +format = MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR; +if (stereo->flags & AV_STEREO3D_FLAG_INVERT) +format++; +break; +} } if (format == MATROSKA_VIDEO_STEREOMODE_TYPE_NB) -return ret; +
[FFmpeg-devel] [PATCH 18/21] avformat/matroskaenc: Move mkv_write_chapters()
This is needed so that it can access mkv_write_tag() and mkv_check_tag() without using forward declarations (which are unnecessary here). Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 118 +++--- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index fad2c18e2b..9103d0a7be 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1435,65 +1435,6 @@ static int mkv_write_tracks(AVFormatContext *s) MATROSKA_ID_TRACKS); } -static int mkv_write_chapters(AVFormatContext *s) -{ -MatroskaMuxContext *mkv = s->priv_data; -AVIOContext *dyn_cp = NULL, *pb = s->pb; -ebml_master editionentry; -AVRational scale = {1, 1E9}; -int i, ret; - -if (!s->nb_chapters || mkv->wrote_chapters) -return 0; - -for (i = 0; i < s->nb_chapters; i++) -if (!s->chapters[i]->id) { -mkv->chapter_id_offset = 1; -break; -} - -ret = start_ebml_master_crc32(&dyn_cp, mkv); -if (ret < 0) -return ret; - -editionentry = start_ebml_master(dyn_cp, MATROSKA_ID_EDITIONENTRY, 0); -if (mkv->mode != MODE_WEBM) -put_ebml_uint(dyn_cp, MATROSKA_ID_EDITIONFLAGDEFAULT, 1); - -for (i = 0; i < s->nb_chapters; i++) { -ebml_master chapteratom, chapterdisplay; -const AVChapter *c = s->chapters[i]; -int64_t chapterstart = av_rescale_q(c->start, c->time_base, scale); -int64_t chapterend = av_rescale_q(c->end, c->time_base, scale); -const AVDictionaryEntry *t; -if (chapterstart < 0 || chapterstart > chapterend || chapterend < 0) { -av_log(s, AV_LOG_ERROR, - "Invalid chapter start (%"PRId64") or end (%"PRId64").\n", - chapterstart, chapterend); -ffio_free_dyn_buf(&dyn_cp); -return AVERROR_INVALIDDATA; -} - -chapteratom = start_ebml_master(dyn_cp, MATROSKA_ID_CHAPTERATOM, 0); -put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERUID, - (uint32_t)c->id + (uint64_t)mkv->chapter_id_offset); -put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMESTART, chapterstart); -put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMEEND, chapterend); -if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { -chapterdisplay = start_ebml_master(dyn_cp, MATROSKA_ID_CHAPTERDISPLAY, 0); -put_ebml_string(dyn_cp, MATROSKA_ID_CHAPSTRING, t->value); -put_ebml_string(dyn_cp, MATROSKA_ID_CHAPLANG , "und"); -end_ebml_master(dyn_cp, chapterdisplay); -} -end_ebml_master(dyn_cp, chapteratom); -} -end_ebml_master(dyn_cp, editionentry); -mkv->wrote_chapters = 1; - -return end_ebml_master_crc32(pb, &dyn_cp, mkv, - MATROSKA_ID_CHAPTERS, 0, 0, 1); -} - static int mkv_write_simpletag(AVIOContext *pb, const AVDictionaryEntry *t) { uint8_t *key = av_strdup(t->key); @@ -1686,6 +1627,65 @@ static int mkv_write_tags(AVFormatContext *s) return 0; } +static int mkv_write_chapters(AVFormatContext *s) +{ +MatroskaMuxContext *mkv = s->priv_data; +AVIOContext *dyn_cp = NULL, *pb = s->pb; +ebml_master editionentry; +AVRational scale = {1, 1E9}; +int i, ret; + +if (!s->nb_chapters || mkv->wrote_chapters) +return 0; + +for (i = 0; i < s->nb_chapters; i++) +if (!s->chapters[i]->id) { +mkv->chapter_id_offset = 1; +break; +} + +ret = start_ebml_master_crc32(&dyn_cp, mkv); +if (ret < 0) +return ret; + +editionentry = start_ebml_master(dyn_cp, MATROSKA_ID_EDITIONENTRY, 0); +if (mkv->mode != MODE_WEBM) +put_ebml_uint(dyn_cp, MATROSKA_ID_EDITIONFLAGDEFAULT, 1); + +for (i = 0; i < s->nb_chapters; i++) { +ebml_master chapteratom, chapterdisplay; +const AVChapter *c = s->chapters[i]; +int64_t chapterstart = av_rescale_q(c->start, c->time_base, scale); +int64_t chapterend = av_rescale_q(c->end, c->time_base, scale); +const AVDictionaryEntry *t; +if (chapterstart < 0 || chapterstart > chapterend || chapterend < 0) { +av_log(s, AV_LOG_ERROR, + "Invalid chapter start (%"PRId64") or end (%"PRId64").\n", + chapterstart, chapterend); +ffio_free_dyn_buf(&dyn_cp); +return AVERROR_INVALIDDATA; +} + +chapteratom = start_ebml_master(dyn_cp, MATROSKA_ID_CHAPTERATOM, 0); +put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERUID, + (uint32_t)c->id + (uint64_t)mkv->chapter_id_offset); +put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMESTART, chapterstart); +put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMEEND, chapterend); +if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { +
[FFmpeg-devel] [PATCH] [libavformat/moc.c] Read the QT Metadata Keys only once
If you have a file with multiple Metadata Keys, the second time you parse the keys, you will re-alloc c->meta_keys without freeing the old one. This change will avoid parsing all the consecutive Metadata keys. --- libavformat/mov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ad718cdaa2..062a62d93b 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7022,7 +7022,8 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) // https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html if (!parse && c->found_hdlr_mdta && atom.type == MKTAG('m','e','t','a') && -a.type == MKTAG('k','e','y','s')) { +a.type == MKTAG('k','e','y','s') && +c->meta_keys_count == 0) { parse = mov_read_keys; } -- 2.26.2.526.g744177e7f7-goog ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC][PATCH] avformat/fifo: add timeshift option to delay output
Signed-off-by: Marton Balint --- libavformat/fifo.c | 59 +- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/libavformat/fifo.c b/libavformat/fifo.c index d11dc6626c..17748e94ce 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -19,6 +19,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "libavutil/avassert.h" #include "libavutil/opt.h" #include "libavutil/time.h" @@ -77,6 +79,9 @@ typedef struct FifoContext { /* Value > 0 signals queue overflow */ volatile uint8_t overflow_flag; +atomic_int_least64_t queue_duration; +int64_t last_sent_dts; +int64_t timeshift; } FifoContext; typedef struct FifoThreadContext { @@ -98,9 +103,12 @@ typedef struct FifoThreadContext { * so finalization by calling write_trailer and ff_io_close must be done * before exiting / reinitialization of underlying muxer */ uint8_t header_written; + +int64_t last_received_dts; } FifoThreadContext; typedef enum FifoMessageType { +FIFO_NOOP, FIFO_WRITE_HEADER, FIFO_WRITE_PACKET, FIFO_FLUSH_OUTPUT @@ -159,6 +167,15 @@ static int fifo_thread_flush_output(FifoThreadContext *ctx) return av_write_frame(avf2, NULL); } +static int64_t next_duration(AVFormatContext *avf, AVPacket *pkt, int64_t *last_dts) +{ +AVStream *st = avf->streams[pkt->stream_index]; +int64_t dts = av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q); +int64_t duration = (*last_dts == AV_NOPTS_VALUE ? 0 : dts - *last_dts); +*last_dts = dts; +return duration; +} + static int fifo_thread_write_packet(FifoThreadContext *ctx, AVPacket *pkt) { AVFormatContext *avf = ctx->avf; @@ -167,6 +184,9 @@ static int fifo_thread_write_packet(FifoThreadContext *ctx, AVPacket *pkt) AVRational src_tb, dst_tb; int ret, s_idx; +if (fifo->timeshift && pkt->dts != AV_NOPTS_VALUE) +atomic_fetch_sub_explicit(&fifo->queue_duration, next_duration(avf, pkt, &ctx->last_received_dts), memory_order_relaxed); + if (ctx->drop_until_keyframe) { if (pkt->flags & AV_PKT_FLAG_KEY) { ctx->drop_until_keyframe = 0; @@ -209,6 +229,9 @@ static int fifo_thread_dispatch_message(FifoThreadContext *ctx, FifoMessage *msg { int ret = AVERROR(EINVAL); +if (msg->type == FIFO_NOOP) +return 0; + if (!ctx->header_written) { ret = fifo_thread_write_header(ctx); if (ret < 0) @@ -390,12 +413,13 @@ static void *fifo_consumer_thread(void *data) AVFormatContext *avf = data; FifoContext *fifo = avf->priv_data; AVThreadMessageQueue *queue = fifo->queue; -FifoMessage msg = {FIFO_WRITE_HEADER, {0}}; +FifoMessage msg = {fifo->timeshift ? FIFO_NOOP : FIFO_WRITE_HEADER, {0}}; int ret; FifoThreadContext fifo_thread_ctx; memset(&fifo_thread_ctx, 0, sizeof(FifoThreadContext)); fifo_thread_ctx.avf = avf; +fifo_thread_ctx.last_received_dts = AV_NOPTS_VALUE; while (1) { uint8_t just_flushed = 0; @@ -429,6 +453,10 @@ static void *fifo_consumer_thread(void *data) if (just_flushed) av_log(avf, AV_LOG_INFO, "FIFO queue flushed\n"); +if (fifo->timeshift) +while (atomic_load_explicit(&fifo->queue_duration, memory_order_relaxed) < fifo->timeshift) +av_usleep(1); + ret = av_thread_message_queue_recv(queue, &msg, 0); if (ret < 0) { av_thread_message_queue_set_err_send(queue, ret); @@ -488,6 +516,8 @@ static int fifo_init(AVFormatContext *avf) " only when drop_pkts_on_overflow is also turned on\n"); return AVERROR(EINVAL); } +atomic_init(&fifo->queue_duration, 0); +fifo->last_sent_dts = AV_NOPTS_VALUE; oformat = av_guess_format(fifo->format, avf->url, NULL); if (!oformat) { @@ -563,6 +593,9 @@ static int fifo_write_packet(AVFormatContext *avf, AVPacket *pkt) goto fail; } +if (fifo->timeshift && pkt->dts != AV_NOPTS_VALUE) +atomic_fetch_add_explicit(&fifo->queue_duration, next_duration(avf, pkt, &fifo->last_sent_dts), memory_order_relaxed); + return ret; fail: if (pkt) @@ -576,6 +609,27 @@ static int fifo_write_trailer(AVFormatContext *avf) int ret; av_thread_message_queue_set_err_recv(fifo->queue, AVERROR_EOF); +if (fifo->timeshift) { +int64_t now = av_gettime_relative(); +int64_t elapsed = 0; +FifoMessage msg = {FIFO_NOOP}; +do { +int64_t delay = av_gettime_relative() - now; +if (delay < 0) { // Discontinuity? +delay = 1; +now = av_gettime_relative(); +} else { +now += delay; +} +atomic_fetch_add_explicit(&fifo->queue_duration, delay, memory_order_relaxed); +elapsed += delay; +if (elapsed > fifo->time
Re: [FFmpeg-devel] [PATCH v4 4/8] avformat/mux: add proper support for full N:M bitstream filtering
On Thu, 7 May 2020, Andreas Rheinhardt wrote: Marton Balint: On Tue, 5 May 2020, Marton Balint wrote: On Tue, 5 May 2020, Andreas Rheinhardt wrote: Marton Balint: On Tue, 5 May 2020, Andreas Rheinhardt wrote: Marton Balint: Previously only 1:1 bitstream filters were supported, the end of the stream was not signalled to the bitstream filters and time base changes were ignored. This change also allows muxers to set up bitstream filters regardless of the autobsf flag during write_header instead of during check_bitstream and those bitstream filters will always be executed. Ignoring the autobsf flag is not ok IMO. The muxer should not add a bsf when the user explicitly didn't want this. The user should not be allowed to create broken files, and the only way to achieve that is to force the BSF. I don't see a use case for disabling BSF either for MXFenc of GXFenc. (in fact, from the top of my head I can't see a use case for disabling automatically inserted BSF-s in other muxers). When automatic bitstream filtering was introduced in 1f9139b07b8a896b62c1f28f3d04acac33978c0d, writing the header of every muxer that potentially might include a bsf automatically (as indicated by the existence of the check_bitstream()-function) was delayed until the first packet would be written. This meant that there was a high probability of having a packet for the relevant stream when using the interleaved codepath. In particular, this meant that the Matroska muxer now received proper extradata for AAC when writing the header even before it received any packet with side data containing potential extradata at all. The reason was that the aac_adtstoasc bsf has simply overwritten the output extradata when dealing with the first packet (that was the old bsf API without init functions; when the new bsf API was merged, the merge commit (not the original commit) propagated the API violating behaviour). 1f6d7eb47070afc4394348721cd149f940ad2386 added the autobsf flag because of this delay: After all, the delay existed as soon as the AVOutputFormat had a check_bitstream function, even when no stream had a codec for which the check_bitstream function would add a bsf at all. As time passed, the API-violating behaviour of aac_adtstoasc was fixed and d6d605eb05c3ca32f591016c345eb2ad9e81c554 stopped delaying writing the header. The very same patchset containing said commit also contained a patch to deprecate AVFMT_FLAG_AUTO_BSF [1]. It was not applied due to concerns what happens when the bsf is not available. (For the record, ff_stream_add_bitstream_filter() will error out if a bsf is not available and the packet discarded. If the caller sends another packet for this stream and a bsf that should be added isn't available the packet will be rejected as well and so on.) The fact that one is forced to include certain automatically inserted bitstream filters even when one knows that one will only use them in scenarios where they merely passthrough the packets is certainly a downside of eliminating this flag. But now that I have reread the history I am nevertheless in favour of deprecation. Wow, thanks for checking this. But if we are moving in the direction of deprecation, then I'd rather not add the extra check to ff_stream_add_bitstream_filter because it will be removed later anyway. Also when I tried to add that, there was a fate failure caused by the segment muxer setting the -autobsf flag but calling the muxer's check_bitstream function directly. Or should I add create a patch which simply removes the -autobsf additional options from segment.c? So considering that autobsf will probably be deprecated anyway can I apply the patch as is? (And finally the series?). According to me: yes. But there is one little detail that I just noticed: write_packets_common() has an AVStream parameter and both of its callers (av_write_frame() and av_interleaved_write_frame() essentially pass s->streams[pkt->stream_index] into it, but don't use it themselves. This parameter should be eliminated and replaced by a local variable in write_packets_common(). Thanks, applied the series with that fix. 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] libavutil: add clean aperture (CLAP) side data.
Neil Birkbeck: > On Tue, Apr 28, 2020 at 3:18 AM Nicolas George wrote: > >> Andreas Rheinhardt (12020-04-28): >>> That's expected. The patch provided only provides the structure in which >>> the values are intended to be exported; it does not add any demuxing or >>> muxing capabilities for mov or mkv (as you can see from the fact that >>> none of these (de)muxers have been changed in the patch). >> >> Which is something I intended to comment on: adding code without users >> is rarely a good idea. I suggest we do not commit until at least one >> demuxer use it, preferably at least two. Otherwise, we may realize that >> “oh crap, it doesn't work” because of a tiny unforeseen detail. > > > Thanks for the feedback. I also have patches for the demux (MOV/MKV) and > mux (MOV/MKV). > > As there is still the alternative of using the fields in the > AVCodecParameters/AVCodecContext, my intention was to keep the first patch > small to resolve discussion on that point. > > I've included the patches, if you'd like to try test it, Kieren. I see on > your test file that there may be some slight rounding error making output > crop 704 not 703 (MKV file ends up with pixel_crop_{left,right} = 8). > > /ffprobe ../testdata/clap.mov 2>&1 | grep -A1 "Side" > Side data: > Clean aperture:[width 41472/59 height:576/1 h_offset:0/1 v_offset:0/1] > ./ffmpeg -i ../testdata/clap.mov -vcodec copy -acodec copy /tmp/clap.mkv > ./ffprobe /tmp/clap.mkv 2>&1 | grep -A1 "Side" > Side data: > Clean aperture:[width 704/1 height:576/1 h_offset:0/1 v_offset:0/1] > > > > Write out stream-level AVCleanAperture side data in the muxer. You should separate the mov and Matroska patches. > > Signed-off-by: Neil Birkbeck > --- > libavformat/matroskaenc.c | 37 + > libavformat/movenc.c | 28 > 2 files changed, 57 insertions(+), 8 deletions(-) > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index 784973a951..19ff29853e 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -901,6 +901,38 @@ static int mkv_write_video_color(AVIOContext *pb, const > AVCodecParameters *par, > return 0; > } > > +static int mkv_write_video_crop(AVIOContext *pb, AVCodecParameters *par, > AVStream *st) > +{ > +int cropb = 0, cropt = 0, cropl = 0, cropr = 0; > +double width, height, h_offset, v_offset; > +int side_data_size = 0; > +const AVCleanAperture *clap = > +(const AVCleanAperture *)av_stream_get_side_data( > +st, AV_PKT_DATA_CLEAN_APERTURE, &side_data_size); > +if (!clap) > +return 0; > + > +width = av_q2d(clap->width); > +height = av_q2d(clap->height); > +h_offset = av_q2d(clap->horizontal_offset); > +v_offset = av_q2d(clap->vertical_offset); > +cropb = (int)(par->height - (par->height / 2. + v_offset + height / 2)); > +cropt = (int)(par->height / 2. + v_offset - height / 2); > +cropr = (int)(par->width - (par->width / 2. + h_offset + width / 2)); > +cropl = (int)(par->width / 2. + h_offset - width / 2); > +cropb = FFMAX(cropb, 0); > +cropt = FFMAX(cropt, 0); > +cropr = FFMAX(cropr, 0); > +cropl = FFMAX(cropl, 0); > +if (!cropr && !cropl && !cropt && !cropb) > +return 0; > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPL, cropl); > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPR, cropr); > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPB, cropb); > +put_ebml_uint(pb, MATROSKA_ID_VIDEOPIXELCROPT, cropt); There is no reason to write all four elements when only some of them are different from zero. > +return 0; > +} > + > static int mkv_write_video_projection(AVFormatContext *s, AVIOContext *pb, >const AVStream *st) > { > @@ -1287,6 +1319,11 @@ static int mkv_write_track(AVFormatContext *s, > MatroskaMuxContext *mkv, > } else if (mkv->mode != MODE_WEBM) > put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYUNIT, > MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN); > > +// Write out pixel crop > +ret = mkv_write_video_crop(pb, par, st); > +if (ret < 0) > +return ret; This is the wrong place for this: It needs to be performed before we write the display dimensions and you need to return the cropped width and height via pointer arguments, so that the code doing display dimensions (which needs to be updated) knows about the cropping. This is necessary, because cropping is supposed to happen before scaling: If the code for writing DisplayWidth/Height didn't know about the real dimensions to scale, it would write the DisplayWidth/Height values that are appropriate for a video with the given pixel aspect ratio and the uncropped pixel dimensions. We should btw error out if someone sends stereo 3d data that implies that a dimension is doubled if cropping is intended to be applied in the same dimension, as this scena
[FFmpeg-devel] [PATCH] avformat/mux: Check pkt->stream_index before using it
This commit fixes two recent regressions both of which are about using pkt->stream_index as index in an AVFormatContext's streams array before actually comparing the value with the count of streams in said array. 96e5e6abb9851d7a26ba21703955d5826ac857c0 did this in prepare_input_packet() and 64063512227c4c87a7d16a1076481dc6baf19841 did likewise in write_packets_common(). Signed-off-by: Andreas Rheinhardt --- The same error in the same file applied on the same day by two different people. How unlikely. libavformat/mux.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index 41659b19c9..f2de73af9b 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -761,12 +761,13 @@ static int check_packet(AVFormatContext *s, AVPacket *pkt) static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt) { +AVStream *st; int ret; -AVStream *st = s->streams[pkt->stream_index]; ret = check_packet(s, pkt); if (ret < 0) return ret; +st = s->streams[pkt->stream_index]; #if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX /* sanitize the timestamps */ @@ -1176,10 +1177,11 @@ static int write_packets_from_bsfs(AVFormatContext *s, AVStream *st, AVPacket *p static int write_packets_common(AVFormatContext *s, AVPacket *pkt, int interleaved) { -AVStream *st = s->streams[pkt->stream_index]; +AVStream *st; int ret = prepare_input_packet(s, pkt); if (ret < 0) return ret; +st = s->streams[pkt->stream_index]; ret = check_bitstream(s, st, pkt); if (ret < 0) -- 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".
Re: [FFmpeg-devel] [PATCH v2 5/5] avcodec/mpegvideo: return more specific error codes for init_duplicate_context()
On Thu, May 07, 2020 at 08:36:50PM +0200, Marton Balint wrote: > > > On Thu, 7 May 2020, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/mpegvideo.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c > > index b5ddb1b..8a74a45 100644 > > --- a/libavcodec/mpegvideo.c > > +++ b/libavcodec/mpegvideo.c > > @@ -359,7 +359,7 @@ static int init_duplicate_context(MpegEncContext *s) > > int y_size = s->b8_stride * (2 * s->mb_height + 1); > > int c_size = s->mb_stride * (s->mb_height + 1); > > int yc_size = y_size + 2 * c_size; > > -int i; > > +int i, ret = AVERROR(ENOMEM); > > ret is uncecessary. > > > > > if (s->mb_height & 1) > > yc_size += 2*s->b8_stride + 2*s->mb_stride; > > @@ -408,7 +408,7 @@ static int init_duplicate_context(MpegEncContext *s) > > > > return 0; > > fail: > > -return -1; // free() through ff_mpv_common_end() > > +return ret; // free() through ff_mpv_common_end() > > Simply return AVERROR(ENOMEM) because all failures are ENOMEM-s. Thanks for review, will update the patch. > > > } > > > > static void free_duplicate_context(MpegEncContext *s) > > -- > > 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". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 4/5] avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()
On Thu, May 07, 2020 at 08:34:44PM +0200, Marton Balint wrote: > > > On Thu, 7 May 2020, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/mpegvideo.c | 14 +++--- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c > > index 22cab28..b5ddb1b 100644 > > --- a/libavcodec/mpegvideo.c > > +++ b/libavcodec/mpegvideo.c > > @@ -889,7 +889,7 @@ static void clear_context(MpegEncContext *s) > > */ > > av_cold int ff_mpv_common_init(MpegEncContext *s) > > { > > -int i, ret; > > +int i, ret = AVERROR(ENOMEM); > > This initialization is unnecessary here, you will overwrite ret later. > > > int nb_slices = (HAVE_THREADS && > > s->avctx->active_thread_type & FF_THREAD_SLICE) ? > > s->avctx->thread_count : 1; > > @@ -907,7 +907,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) > > if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { > > av_log(s->avctx, AV_LOG_ERROR, > >"decoding to AV_PIX_FMT_NONE is not supported.\n"); > > -return -1; > > +return AVERROR(EINVAL); > > } > > > > if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && > > s->mb_height)) { > > @@ -923,7 +923,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) > > > > if ((s->width || s->height) && > > av_image_check_size(s->width, s->height, 0, s->avctx)) > > -return -1; > > +return AVERROR(EINVAL); > > > > dct_init(s); > > > > @@ -954,7 +954,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) > > if (!s->new_picture.f) > > goto fail; > > > > -if (init_context_frame(s)) > > +if ((ret = init_context_frame(s))) > > goto fail; > > > > s->parse_context.state = -1; > > @@ -971,7 +971,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) > > if (!s->thread_context[i]) > > goto fail; > > } > > -if (init_duplicate_context(s->thread_context[i]) < 0) > > +if ((ret = init_duplicate_context(s->thread_context[i])) < 0) > > goto fail; > > s->thread_context[i]->start_mb_y = > > (s->mb_height * (i) + nb_slices / 2) / nb_slices; > > @@ -979,7 +979,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) > > (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; > > } > > } else { > > -if (init_duplicate_context(s) < 0) > > +if ((ret = init_duplicate_context(s)) < 0) > > goto fail; > > s->start_mb_y = 0; > > s->end_mb_y = s->mb_height; > > @@ -990,7 +990,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) > > return 0; > > fail: > > ff_mpv_common_end(s); > > -return -1; > > +return ret > > Not all goto fail set ret. I think it is cleaner if you add a new label > "fail_nomem" before the fail label and set ret to ENOMEM there, and use that > label for ENOMEM cases. thanks for review, will update to add fail_nomem label. > > 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". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 4/5] avcodec/mpegvideo: return more specific error codes for ff_mpv_common_init()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 22cab28..5101e97 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -907,7 +907,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { av_log(s->avctx, AV_LOG_ERROR, "decoding to AV_PIX_FMT_NONE is not supported.\n"); -return -1; +return AVERROR(EINVAL); } if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) { @@ -923,7 +923,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if ((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) -return -1; +return AVERROR(EINVAL); dct_init(s); @@ -935,27 +935,27 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) return ret; FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, - MAX_PICTURE_COUNT * sizeof(Picture), fail); + MAX_PICTURE_COUNT * sizeof(Picture), fail_nomem); for (i = 0; i < MAX_PICTURE_COUNT; i++) { s->picture[i].f = av_frame_alloc(); if (!s->picture[i].f) -goto fail; +goto fail_nomem; } s->next_picture.f = av_frame_alloc(); if (!s->next_picture.f) -goto fail; +goto fail_nomem; s->last_picture.f = av_frame_alloc(); if (!s->last_picture.f) -goto fail; +goto fail_nomem; s->current_picture.f = av_frame_alloc(); if (!s->current_picture.f) -goto fail; +goto fail_nomem; s->new_picture.f = av_frame_alloc(); if (!s->new_picture.f) -goto fail; +goto fail_nomem; -if (init_context_frame(s)) -goto fail; +if ((ret = init_context_frame(s))) +goto fail_nomem; s->parse_context.state = -1; @@ -969,9 +969,9 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (i) { s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext)); if (!s->thread_context[i]) -goto fail; +goto fail_nomem; } -if (init_duplicate_context(s->thread_context[i]) < 0) +if ((ret = init_duplicate_context(s->thread_context[i])) < 0) goto fail; s->thread_context[i]->start_mb_y = (s->mb_height * (i) + nb_slices / 2) / nb_slices; @@ -979,7 +979,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; } } else { -if (init_duplicate_context(s) < 0) +if ((ret = init_duplicate_context(s)) < 0) goto fail; s->start_mb_y = 0; s->end_mb_y = s->mb_height; @@ -988,9 +988,11 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) // } return 0; + fail_nomem: +ret = AVERROR(ENOMEM); fail: ff_mpv_common_end(s); -return -1; +return ret; } /** -- 2.6.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 5/5] avcodec/mpegvideo: return more specific error codes for init_duplicate_context()
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpegvideo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 5101e97..dd3b925 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -408,7 +408,7 @@ static int init_duplicate_context(MpegEncContext *s) return 0; fail: -return -1; // free() through ff_mpv_common_end() +return AVERROR(ENOMEM); // free() through ff_mpv_common_end() } static void free_duplicate_context(MpegEncContext *s) -- 2.6.4 ___ 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 5/5] avfilter/vf_signalstats: reindent after last commit
On Mon, Dec 30, 2019 at 07:09:58PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavfilter/vf_signalstats.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c > index 8b2a9ca7c2..1ccc16dd38 100644 > --- a/libavfilter/vf_signalstats.c > +++ b/libavfilter/vf_signalstats.c > @@ -168,13 +168,13 @@ static int config_output(AVFilterLink *outlink) > s->vsub = desc->log2_chroma_h; > s->depth = desc->comp[0].depth; > s->maxsize = 1 << s->depth; > -s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy)); > -s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu)); > -s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv)); > -s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat)); > +s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy)); > +s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu)); > +s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv)); > +s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat)); > > -if (!s->histy || !s->histu || !s->histv || !s->histsat) > -return AVERROR(ENOMEM); > +if (!s->histy || !s->histu || !s->histv || !s->histsat) > +return AVERROR(ENOMEM); > > outlink->w = inlink->w; > outlink->h = inlink->h; > -- > 2.21.0 > ping for th patchset for review. -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/fifo: add options to slow down writing packets to match real time approximately
Marton Balint 于2020年5月7日周四 下午6:23写道: > > > > On Thu, 7 May 2020, leozhang wrote: > > > Suggested-by: Nicolas George > > Reviewed-by: Nicolas George > > Reviewed-by: Marton Balint > > Reviewed-by: Andreas Rheinhardt > > You seem to misunderstand the use of this tag. You should only add these > if you received an explict LGTM for your patches. This has not happened > here, you only got suggestions, and those suggestions were concerning your > earlier patch versions. Yes, I have. Please ignore above Reviewed-by > > Also, what happened to the suggestion of using a buffer based approach and > using realtime only for flushing? I will code something, and see how it > goes, and will post a result as an RFC patch. I didn't try using a buffer based approach in fifo.c. If you're willing to post such RFC patch, I'm OK. Thanks > > Regards, > Marton > > > > Signed-off-by: leozhang > > --- > > doc/muxers.texi| 21 + > > libavformat/fifo.c | 46 ++ > > 2 files changed, 67 insertions(+) > > > > diff --git a/doc/muxers.texi b/doc/muxers.texi > > index 536433b..14528f1 100644 > > --- a/doc/muxers.texi > > +++ b/doc/muxers.texi > > @@ -2274,6 +2274,17 @@ certain (usually permanent) errors the recovery is > > not attempted even when > > Specify whether to wait for the keyframe after recovering from > > queue overflow or failure. This option is set to 0 (false) by default. > > > > +@item realtime @var{bool} > > +If set to 1 (true), slow down writing packets to match real time > > approximately. > > +This is similar to @ref{the realtime or arealtime filters,,the > > "realtime_002c-arealtime" section in the ffmpeg-filters > > manual,ffmpeg-filters}. > > +Please note that in some cases without filtering, such as stream copy, you > > can also use it. > > + > > +@item realtime_speed > > +It is the same as the speed option to realtime or arealtime filters. > > + > > +@item realtime_limit @var{duration} > > +It is the same as the limit option to realtime or arealtime filters. > > + > > @end table > > > > @subsection Examples > > @@ -2291,6 +2302,16 @@ ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo > > -fifo_format flv -map 0:v -map 0 > > > > @end itemize > > > > +@itemize > > + > > +@item > > +Stream something to rtmp server, instead of using -re option. > > +@example > > +ffmpeg -i your_input_file -c copy -map 0:v -map 0:a -f fifo -fifo_format > > flv -realtime 1 rtmp://example.com/live/stream_name > > +@end example > > + > > +@end itemize > > + > > @anchor{tee} > > @section tee > > > > diff --git a/libavformat/fifo.c b/libavformat/fifo.c > > index d11dc66..7acc420 100644 > > --- a/libavformat/fifo.c > > +++ b/libavformat/fifo.c > > @@ -26,6 +26,7 @@ > > #include "libavutil/threadmessage.h" > > #include "avformat.h" > > #include "internal.h" > > +#include > > > > #define FIFO_DEFAULT_QUEUE_SIZE 60 > > #define FIFO_DEFAULT_MAX_RECOVERY_ATTEMPTS 0 > > @@ -77,6 +78,17 @@ typedef struct FifoContext { > > /* Value > 0 signals queue overflow */ > > volatile uint8_t overflow_flag; > > > > +/* Slow down writing packets to match real time approximately */ > > +int realtime; > > + > > +/* Speed factor for the processing when realtime */ > > +double realtime_speed; > > + > > +/* Time limit for the pauses when realtime */ > > +int64_t realtime_limit; > > + > > +int64_t delta; > > +unsigned inited; > > } FifoContext; > > > > typedef struct FifoThreadContext { > > @@ -183,6 +195,31 @@ static int fifo_thread_write_packet(FifoThreadContext > > *ctx, AVPacket *pkt) > > dst_tb = avf2->streams[s_idx]->time_base; > > av_packet_rescale_ts(pkt, src_tb, dst_tb); > > > > +if (fifo->realtime) { > > +int64_t pts = av_rescale_q(pkt->dts, dst_tb, AV_TIME_BASE_Q) / > > fifo->realtime_speed; > > +int64_t now = av_gettime_relative(); > > +int64_t sleep = pts - now + fifo->delta; > > + > > +if (!fifo->inited) { > > +sleep = 0; > > +fifo->delta = now - pts; > > +fifo->inited = 1; > > +} > > + > > +if (FFABS(sleep) > fifo->realtime_limit / fifo->realtime_speed) { > > +av_log(avf, AV_LOG_WARNING, "time discontinuity detected: > > %"PRIi64" us, resetting\n", sleep); > > +sleep = 0; > > +fifo->delta = now - pts; > > +} > > + > > +if (sleep > 0) { > > +av_log(avf, AV_LOG_DEBUG, "sleeping %"PRIi64" us\n", sleep); > > +for (; sleep > 6; sleep -= 6) > > +av_usleep(6); > > +av_usleep(sleep); > > +} > > +} > > + > > ret = av_write_frame(avf2, pkt); > > if (ret >= 0) > > av_packet_unref(pkt); > > @@ -630,6 +667,15 @@ static const AVOption options[] = { > > {"recover_any_error", "Attempt recovery regardless of type of the > > error", OFFSET(recover_any_error), > > AV_OPT_TY
Re: [FFmpeg-devel] [PATCH v1 1/4] avcodec/lcldec: remove the unnecessary type conversion
On Thu, Sep 12, 2019 at 12:55:09PM +0200, Carl Eugen Hoyos wrote: > Am Do., 12. Sept. 2019 um 11:24 Uhr schrieb : > > > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/lcldec.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c > > index 046cdc4f8e..1154221f8f 100644 > > --- a/libavcodec/lcldec.c > > +++ b/libavcodec/lcldec.c > > @@ -136,7 +136,7 @@ static int zlib_decomp(AVCodecContext *avctx, const > > uint8_t *src, int src_len, i > > av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret); > > return AVERROR_UNKNOWN; > > } > > -c->zstream.next_in = (uint8_t *)src; > > +c->zstream.next_in = src; > > I prefer this patchset, others may disagree. will apply the patchset. > > Thank you, Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/h264: support sps/pps AV_PKT_DATA_NEW_EXTRADATA
https://github.com/FFmpeg/FFmpeg/commit/601c238 added support for AV_PKT_DATA_NEW_EXTRADATA, but only for avcC extradata. This commit adds support for sps/pps extradata as well. This makes support consistent for passing new extradata consistent with the types of extradata that can be passed when initializing the decoder. Signed-off-by: Oliver Woodman --- libavcodec/h264dec.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 4c355feb18..c1d103a474 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -829,7 +829,7 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp) return 0; } -static int is_extra(const uint8_t *buf, int buf_size) +static int is_avcc_extradata(const uint8_t *buf, int buf_size) { int cnt= buf[5]&0x1f; const uint8_t *p= buf+6; @@ -956,16 +956,15 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data, if (buf_size == 0) return send_next_delayed_frame(h, pict, got_frame, 0); -if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) { +if (av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) { int side_size; uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); -if (is_extra(side, side_size)) -ff_h264_decode_extradata(side, side_size, - &h->ps, &h->is_avc, &h->nal_length_size, - avctx->err_recognition, avctx); +ff_h264_decode_extradata(side, side_size, + &h->ps, &h->is_avc, &h->nal_length_size, + avctx->err_recognition, avctx); } if (h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC) { -if (is_extra(buf, buf_size)) +if (is_avcc_extradata(buf, buf_size)) return ff_h264_decode_extradata(buf, buf_size, &h->ps, &h->is_avc, &h->nal_length_size, avctx->err_recognition, avctx); -- 2.26.0.110.g2183baf09c-goog ___ 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".