[FFmpeg-devel] [PATCH] modified frame timing, so that we can make sure that a frame is never forward in time with respect to the original one, when converting from VFR to CFR
--- fftools/ffmpeg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 46bb014de8..8085442156 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1238,8 +1238,9 @@ static void do_video_out(OutputFile *of, nb_frames = 0; } else if (delta < -1.1) nb_frames = 0; -else if (delta > 1.1) { -nb_frames = lrintf(delta); +// let the CFR frame go backward by at most one frame duration with respect to the original VFR +else if (delta >= 2) { +nb_frames = floor(delta); if (delta0 > 1.1) nb0_frames = llrintf(delta0 - 0.6); } -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/6] avutil/adler32: Switch av_adler32_update() to size_t on bump
av_adler32_update() is used by av_hash_update() which will be switched to size_t at the next bump. So it also has to be made to use size_t. This is also necessary for framecrcenc.c, because the size of side data will become a size_t, too. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 5 + libavutil/adler32.c | 4 libavutil/adler32.h | 16 ++-- libavutil/version.h | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 849d95a7ed..1782ae83fe 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,11 @@ libavutil: 2017-10-21 API changes, most recent first: +2021-03-18 - xx - lavu 56.69.100 - adler32.h + av_adler32_update() will be changed to use uint32_t + for the Adler-32 checksums and size_t for the length + if the input buffer at the next bump. + 2021-03-xx - xx - lavc 58.133.100 - codec.h Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will no longer be a part of the public ABI. diff --git a/libavutil/adler32.c b/libavutil/adler32.c index c87d5e261c..5ed5ff55a3 100644 --- a/libavutil/adler32.c +++ b/libavutil/adler32.c @@ -41,8 +41,12 @@ #define DO4(buf) DO1(buf); DO1(buf); DO1(buf); DO1(buf); #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf); +#if FF_API_CRYPTO_SIZE_T unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf, unsigned int len) +#else +AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len) +#endif { unsigned long s1 = adler & 0x; unsigned long s2 = adler >> 16; diff --git a/libavutil/adler32.h b/libavutil/adler32.h index a1f035b734..e7a8f83729 100644 --- a/libavutil/adler32.h +++ b/libavutil/adler32.h @@ -27,8 +27,10 @@ #ifndef AVUTIL_ADLER32_H #define AVUTIL_ADLER32_H +#include #include #include "attributes.h" +#include "version.h" /** * @defgroup lavu_adler32 Adler-32 @@ -38,6 +40,12 @@ * @{ */ +#if FF_API_CRYPTO_SIZE_T +typedef unsigned long AVAdler; +#else +typedef uint32_t AVAdler; +#endif + /** * Calculate the Adler32 checksum of a buffer. * @@ -50,8 +58,12 @@ * @param len size of input buffer * @return updated checksum */ -unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, -unsigned int len) av_pure; +AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, +#if FF_API_CRYPTO_SIZE_T + unsigned int len) av_pure; +#else + size_t len) av_pure; +#endif /** * @} diff --git a/libavutil/version.h b/libavutil/version.h index 9a290d57e7..f357f6165e 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 68 +#define LIBAVUTIL_VERSION_MINOR 69 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 5/6] Fix printf specifiers for variables that will be switched to size_t
Also fix some minor stuff like switching loop counters to size_t. Signed-off-by: Andreas Rheinhardt --- Now using a special define for the specifier instead of lots of #if. libavcodec/decode.c| 3 ++- libavcodec/mpeg12enc.c | 4 ++-- libavcodec/mscc.c | 3 ++- libavfilter/af_ashowinfo.c | 3 ++- libavfilter/vf_showinfo.c | 10 ++ libavformat/dump.c | 4 ++-- libavformat/framecrcenc.c | 5 +++-- libavformat/hashenc.c | 7 --- libavformat/matroskaenc.c | 3 ++- libavformat/webvttdec.c| 2 +- libavformat/webvttenc.c| 18 ++ libavutil/internal.h | 2 ++ 12 files changed, 42 insertions(+), 22 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index efa8a9ac8d..c923b3e240 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -2061,7 +2061,8 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) memcpy(dst, pal, AVPALETTE_SIZE); return 1; } else if (pal) { -av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); +av_log(logctx, AV_LOG_ERROR, + "Palette size %"BUFFER_SPECIFIER" is wrong\n", size); } return 0; } diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index a05c2db6cb..771c9996a5 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -574,8 +574,8 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) put_bits(>pb, 8, 0xff); // marker_bits } else { av_log(s->avctx, AV_LOG_WARNING, -"Warning Closed Caption size (%d) can not exceed 93 bytes " -"and must be a multiple of 3\n", side_data->size); +"Closed Caption size (%"BUFFER_SPECIFIER") can not exceed " +"93 bytes and must be a multiple of 3\n", side_data->size); } } } diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c index fe02649623..08ae8cdbad 100644 --- a/libavcodec/mscc.c +++ b/libavcodec/mscc.c @@ -160,7 +160,8 @@ static int decode_frame(AVCodecContext *avctx, for (j = 0; j < 256; j++) s->pal[j] = 0xFF00 | AV_RL32(pal + j * 4); } else if (pal) { -av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); +av_log(avctx, AV_LOG_ERROR, + "Palette size %"BUFFER_SPECIFIER" is wrong\n", size); } memcpy(frame->data[1], s->pal, AVPALETTE_SIZE); } diff --git a/libavfilter/af_ashowinfo.c b/libavfilter/af_ashowinfo.c index 9046e8d84a..e7b1d92e3d 100644 --- a/libavfilter/af_ashowinfo.c +++ b/libavfilter/af_ashowinfo.c @@ -170,7 +170,8 @@ static void dump_audio_service_type(AVFilterContext *ctx, AVFrameSideData *sd) static void dump_unknown(AVFilterContext *ctx, AVFrameSideData *sd) { -av_log(ctx, AV_LOG_INFO, "unknown side data type: %d, size %d bytes", sd->type, sd->size); +av_log(ctx, AV_LOG_INFO, "unknown side data type: %d, size " + "%"BUFFER_SPECIFIER" bytes", sd->type, sd->size); } static int filter_frame(AVFilterLink *inlink, AVFrame *buf) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 6208892005..21577dce7e 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -314,7 +314,8 @@ static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSi int i; if (sd->size < uuid_size) { -av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))\n", sd->size, uuid_size); +av_log(ctx, AV_LOG_ERROR, "invalid data(%"BUFFER_SPECIFIER" < " + "UUID(%d-bytes))\n", sd->size, uuid_size); return; } @@ -472,7 +473,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) av_log(ctx, AV_LOG_INFO, "pan/scan"); break; case AV_FRAME_DATA_A53_CC: -av_log(ctx, AV_LOG_INFO, "A/53 closed captions (%d bytes)", sd->size); +av_log(ctx, AV_LOG_INFO, "A/53 closed captions " + "(%"BUFFER_SPECIFIER" bytes)", sd->size); break; case AV_FRAME_DATA_SPHERICAL: dump_spherical(ctx, frame, sd); @@ -516,8 +518,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) dump_sei_unregistered_metadata(ctx, sd); break; default: -av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)\n", - sd->type, sd->size); +av_log(ctx, AV_LOG_WARNING, "unknown side data type %d " + "(%"BUFFER_SPECIFIER" bytes)\n", sd->type, sd->size); break; } diff --git a/libavformat/dump.c b/libavformat/dump.c index 62ef5e9852..7b312f80a3 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -495,8 +495,8 @@ static void dump_sidedata(void *ctx, const AVStream *st, const char *indent)
Re: [FFmpeg-devel] [PATCH 2/5] avcodec/packet: Also change av_packet_pack/unpack_dictionary to size_t
On 3/17/2021 8:59 PM, Andreas Rheinhardt wrote: These are auxiliary side-data functions, so they should have been switched to size_t in d79e0fe65c51491f9bf8a470bbe36fb09f3e1280, but this has been forgotten. Signed-off-by: Andreas Rheinhardt --- libavcodec/avpacket.c| 13 + libavcodec/packet.h | 10 +- libavdevice/decklink_dec.cpp | 2 +- libavdevice/lavfi.c | 2 +- libavformat/concatdec.c | 2 +- libavformat/img2dec.c| 3 ++- libavformat/oggdec.h | 2 +- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 8f0850fb00..b5bac5c5f2 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -507,7 +507,11 @@ int av_packet_split_side_data(AVPacket *pkt){ } #endif +#if FF_API_BUFFER_SIZE_T uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) +#else +uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size) +#endif { uint8_t *data = NULL; *size = 0; @@ -526,7 +530,11 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) if (pass) memcpy(data + total_length, str, len); +#if FF_API_BUFFER_SIZE_T else if (len > INT_MAX - total_length) +#else +else if (len > SIZE_MAX - total_length) +#endif return NULL; total_length += len; } @@ -542,7 +550,12 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) return data; } +#if FF_API_BUFFER_SIZE_T int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) +#else +int av_packet_unpack_dictionary(const uint8_t *data, size_t size, +AVDictionary **dict) +#endif You can use buffer_size_t to reduce the ifdeffery in both cases. { const uint8_t *end; int ret; diff --git a/libavcodec/packet.h b/libavcodec/packet.h index da4377e09f..ca18ae631f 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -647,7 +647,11 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type); * @param size pointer to store the size of the returned data * @return pointer to data if successful, NULL otherwise */ +#if FF_API_BUFFER_SIZE_T uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); +#else +uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size); +#endif /** * Unpack a dictionary from side_data. * @@ -656,8 +660,12 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); * @param dict the metadata storage dictionary * @return 0 on success, < 0 on failure */ +#if FF_API_BUFFER_SIZE_T int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict); - +#else +int av_packet_unpack_dictionary(const uint8_t *data, size_t size, +AVDictionary **dict); +#endif /** * Convenience function to free all the side data stored. diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 40c3dae968..79d96cd620 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -922,7 +922,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( const char *tc = av_timecode_make_string(, tcstr, 0); if (tc) { AVDictionary* metadata_dict = NULL; -int metadata_len; uint8_t* packed_metadata; if (av_cmp_q(ctx->video_st->r_frame_rate, av_make_q(60, 1)) < 1) { @@ -937,6 +936,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( } if (av_dict_set(_dict, "timecode", tc, 0) >= 0) { +buffer_size_t metadata_len; packed_metadata = av_packet_pack_dictionary(metadata_dict, _len); av_dict_free(_dict); if (packed_metadata) { diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 94ad03268a..fdadff3f7f 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -446,7 +446,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) frame_metadata = frame->metadata; if (frame_metadata) { -int size; +buffer_size_t size; uint8_t *metadata = av_packet_pack_dictionary(frame_metadata, ); if (!metadata) { diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 6d5b9914f9..32d4a99010 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -626,7 +626,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base)); if
Re: [FFmpeg-devel] [PATCH 3/5] avcodec: Factor updating palette out
Andreas Rheinhardt: > James Almer: >> On 3/17/2021 8:59 PM, Andreas Rheinhardt wrote: >>> Because the properties of frames returned from ff_get/reget_buffer >>> are not reset at all, lots of returned frames had palette_has_changed >>> wrongly set to 1. This has been changed, too. >>> >>> Signed-off-by: Andreas Rheinhardt >>> --- >>> libavcodec/8bps.c | 11 +-- >>> libavcodec/cinepak.c | 9 + >>> libavcodec/decode.c | 14 ++ >>> libavcodec/gdv.c | 5 + >>> libavcodec/idcinvideo.c | 9 + >>> libavcodec/imx.c | 5 + >>> libavcodec/internal.h | 9 + >>> libavcodec/interplayvideo.c | 9 + >>> libavcodec/kmvc.c | 8 +--- >>> libavcodec/msrle.c | 11 ++- >>> libavcodec/msvideo1.c | 10 +- >>> libavcodec/qpeg.c | 9 + >>> libavcodec/qtrle.c | 10 +- >>> libavcodec/rawdec.c | 13 ++--- >>> libavcodec/rscc.c | 13 ++--- >>> libavcodec/smc.c | 9 + >>> libavcodec/tscc.c | 10 +- >>> 17 files changed, 41 insertions(+), 123 deletions(-) >>> >> >> [...] >> >>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c >>> index 5a00aeedae..efa8a9ac8d 100644 >>> --- a/libavcodec/decode.c >>> +++ b/libavcodec/decode.c >>> @@ -2051,3 +2051,17 @@ FF_ENABLE_DEPRECATION_WARNINGS >>> return 0; >>> } >>> + >>> +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) >> >> All the arguments for dst are uint8_t*. > > Actually, most of them are uint32_t*. The only (?) exception is > rawdec.c. (An earlier version of this patch used "uint32_t > dst[AVPALETTE_SIZE]" with a cast for rawdec, but then I noticed that > this is of by a factor of sizeof(uint32_t).) > rscc.c is also an exception. >> >>> +{ >>> + buffer_size_t size; >>> + const void *pal = av_packet_get_side_data(src, >>> AV_PKT_DATA_PALETTE, ); >> >> Same, av_packet_get_side_data() returns an uint8_t*. > > Yes, but it actually is an array of uint32_t, hence void*. (void* is a > better return value for av_packet_get_side_data() anyway, as most of the > side data types are structures. Maybe we should change that.) > >> >>> + >>> + if (pal && size == AVPALETTE_SIZE) { >>> + memcpy(dst, pal, AVPALETTE_SIZE); >>> + return 1; >>> + } else if (pal) { >>> + av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", >>> size); >>> + } >>> + return 0; >>> +} >> >> [...] >> >>> diff --git a/libavcodec/internal.h b/libavcodec/internal.h >>> index b57b996816..0fb3107979 100644 >>> --- a/libavcodec/internal.h >>> +++ b/libavcodec/internal.h >>> @@ -393,6 +393,15 @@ int ff_int_from_list_or_default(void *ctx, const >>> char * val_name, int val, >>> void ff_dvdsub_parse_palette(uint32_t *palette, const char *p); >>> +/** >>> + * Check whether the side-data of src contains a palette of >>> + * size AVPALETTE_SIZE; if so, copy it to dst and return 1; >>> + * else return 0. >>> + * Also emit an error message upon encountering a palette >>> + * with invalid size. >>> + */ >>> +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); >> >> Should be in libavcodec/decode.h instead. > > It was in decode.h until I noticed that most decoders don't include that > header. internal.h includes several other functions that are only used > by decoders (like ff_reget_buffer). But, yes, will move it. > >> >> Or maybe avpacket.c and packet_internal.h, for that matter. > > Given that it is only used by decoders, decode.c seems the appropriate > place (is it noticeable that I dream of a day when all the decoding code > is really disabled when there are no decoders enabled?). > >> >>> + >>> #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec) >>> # define av_export_avcodec __declspec(dllimport) >>> #else > ___ 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] added parameter to dash encoder for start available time
--- libavformat/dashenc.c | 28 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 24d43c34ea..81855ca8d0 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -149,6 +149,7 @@ typedef struct DASHContext { int master_publish_rate; int nr_of_streams_to_flush; int nr_of_streams_flushed; +int64_t start_time_ms; } DASHContext; static struct codec_string { @@ -725,13 +726,11 @@ static void write_time(AVIOContext *out, int64_t time) avio_printf(out, "%d.%dS", seconds, fractions / (AV_TIME_BASE / 10)); } -static void format_date_now(char *buf, int size) +static void format_date(uint64_t epoch_ms, char *buf, int size) { struct tm *ptm, tmbuf; -int64_t time_us = av_gettime(); -int64_t time_ms = time_us / 1000; -const time_t time_s = time_ms / 1000; -int millisec = time_ms - (time_s * 1000); +const time_t time_s = epoch_ms / 1000; +int millisec = epoch_ms - (time_s * 1000); ptm = gmtime_r(_s, ); if (ptm) { int len; @@ -744,6 +743,12 @@ static void format_date_now(char *buf, int size) } } +static void format_date_now(char *buf, int size) +{ +int64_t time_us = av_gettime(); +format_date( time_us / 1000, buf, size); +} + static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_index, int final) { @@ -1712,10 +1717,16 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) os->last_pts = pkt->pts; if (!c->availability_start_time[0]) { -int64_t start_time_us = av_gettime(); -c->start_time_s = start_time_us / 100; -format_date_now(c->availability_start_time, +if (c->start_time_ms) { +c->start_time_s = c->start_time_ms / 1000; +format_date(c->start_time_ms, c->availability_start_time, sizeof(c->availability_start_time)); +} else { +int64_t start_time_us = av_gettime(); +c->start_time_s = start_time_us / 100; +format_date_now(c->availability_start_time, +sizeof(c->availability_start_time)); +} } if (!os->availability_time_offset && pkt->duration) { @@ -1922,6 +1933,7 @@ static const AVOption options[] = { { "ignore_io_errors", "Ignore IO errors during open and write. Useful for long-duration runs with network output", OFFSET(ignore_io_errors), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, { "lhls", "Enable Low-latency HLS(Experimental). Adds #EXT-X-PREFETCH tag with current segment's URI", OFFSET(lhls), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, { "master_m3u8_publish_rate", "Publish master playlist every after this many segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX, E}, +{ "start_time_ms", "stream start time in epoch milliseconds", OFFSET(start_time_ms), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, UINT64_MAX, E, "ms"}, { NULL }, }; -- 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 3/5] avcodec: Factor updating palette out
James Almer: > On 3/17/2021 8:59 PM, Andreas Rheinhardt wrote: >> Because the properties of frames returned from ff_get/reget_buffer >> are not reset at all, lots of returned frames had palette_has_changed >> wrongly set to 1. This has been changed, too. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/8bps.c | 11 +-- >> libavcodec/cinepak.c | 9 + >> libavcodec/decode.c | 14 ++ >> libavcodec/gdv.c | 5 + >> libavcodec/idcinvideo.c | 9 + >> libavcodec/imx.c | 5 + >> libavcodec/internal.h | 9 + >> libavcodec/interplayvideo.c | 9 + >> libavcodec/kmvc.c | 8 +--- >> libavcodec/msrle.c | 11 ++- >> libavcodec/msvideo1.c | 10 +- >> libavcodec/qpeg.c | 9 + >> libavcodec/qtrle.c | 10 +- >> libavcodec/rawdec.c | 13 ++--- >> libavcodec/rscc.c | 13 ++--- >> libavcodec/smc.c | 9 + >> libavcodec/tscc.c | 10 +- >> 17 files changed, 41 insertions(+), 123 deletions(-) >> > > [...] > >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c >> index 5a00aeedae..efa8a9ac8d 100644 >> --- a/libavcodec/decode.c >> +++ b/libavcodec/decode.c >> @@ -2051,3 +2051,17 @@ FF_ENABLE_DEPRECATION_WARNINGS >> return 0; >> } >> + >> +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) > > All the arguments for dst are uint8_t*. Actually, most of them are uint32_t*. The only (?) exception is rawdec.c. (An earlier version of this patch used "uint32_t dst[AVPALETTE_SIZE]" with a cast for rawdec, but then I noticed that this is of by a factor of sizeof(uint32_t).) > >> +{ >> + buffer_size_t size; >> + const void *pal = av_packet_get_side_data(src, >> AV_PKT_DATA_PALETTE, ); > > Same, av_packet_get_side_data() returns an uint8_t*. Yes, but it actually is an array of uint32_t, hence void*. (void* is a better return value for av_packet_get_side_data() anyway, as most of the side data types are structures. Maybe we should change that.) > >> + >> + if (pal && size == AVPALETTE_SIZE) { >> + memcpy(dst, pal, AVPALETTE_SIZE); >> + return 1; >> + } else if (pal) { >> + av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", >> size); >> + } >> + return 0; >> +} > > [...] > >> diff --git a/libavcodec/internal.h b/libavcodec/internal.h >> index b57b996816..0fb3107979 100644 >> --- a/libavcodec/internal.h >> +++ b/libavcodec/internal.h >> @@ -393,6 +393,15 @@ int ff_int_from_list_or_default(void *ctx, const >> char * val_name, int val, >> void ff_dvdsub_parse_palette(uint32_t *palette, const char *p); >> +/** >> + * Check whether the side-data of src contains a palette of >> + * size AVPALETTE_SIZE; if so, copy it to dst and return 1; >> + * else return 0. >> + * Also emit an error message upon encountering a palette >> + * with invalid size. >> + */ >> +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); > > Should be in libavcodec/decode.h instead. It was in decode.h until I noticed that most decoders don't include that header. internal.h includes several other functions that are only used by decoders (like ff_reget_buffer). But, yes, will move it. > > Or maybe avpacket.c and packet_internal.h, for that matter. Given that it is only used by decoders, decode.c seems the appropriate place (is it noticeable that I dream of a day when all the decoding code is really disabled when there are no decoders enabled?). > >> + >> #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec) >> # define av_export_avcodec __declspec(dllimport) >> #else ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/5] avcodec: Factor updating palette out
On 3/17/2021 8:59 PM, Andreas Rheinhardt wrote: Because the properties of frames returned from ff_get/reget_buffer are not reset at all, lots of returned frames had palette_has_changed wrongly set to 1. This has been changed, too. Signed-off-by: Andreas Rheinhardt --- libavcodec/8bps.c | 11 +-- libavcodec/cinepak.c| 9 + libavcodec/decode.c | 14 ++ libavcodec/gdv.c| 5 + libavcodec/idcinvideo.c | 9 + libavcodec/imx.c| 5 + libavcodec/internal.h | 9 + libavcodec/interplayvideo.c | 9 + libavcodec/kmvc.c | 8 +--- libavcodec/msrle.c | 11 ++- libavcodec/msvideo1.c | 10 +- libavcodec/qpeg.c | 9 + libavcodec/qtrle.c | 10 +- libavcodec/rawdec.c | 13 ++--- libavcodec/rscc.c | 13 ++--- libavcodec/smc.c| 9 + libavcodec/tscc.c | 10 +- 17 files changed, 41 insertions(+), 123 deletions(-) [...] diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 5a00aeedae..efa8a9ac8d 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -2051,3 +2051,17 @@ FF_ENABLE_DEPRECATION_WARNINGS return 0; } + +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) All the arguments for dst are uint8_t*. +{ +buffer_size_t size; +const void *pal = av_packet_get_side_data(src, AV_PKT_DATA_PALETTE, ); Same, av_packet_get_side_data() returns an uint8_t*. + +if (pal && size == AVPALETTE_SIZE) { +memcpy(dst, pal, AVPALETTE_SIZE); +return 1; +} else if (pal) { +av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); +} +return 0; +} [...] diff --git a/libavcodec/internal.h b/libavcodec/internal.h index b57b996816..0fb3107979 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -393,6 +393,15 @@ int ff_int_from_list_or_default(void *ctx, const char * val_name, int val, void ff_dvdsub_parse_palette(uint32_t *palette, const char *p); +/** + * Check whether the side-data of src contains a palette of + * size AVPALETTE_SIZE; if so, copy it to dst and return 1; + * else return 0. + * Also emit an error message upon encountering a palette + * with invalid size. + */ +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); Should be in libavcodec/decode.h instead. Or maybe avpacket.c and packet_internal.h, for that matter. + #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec) #define av_export_avcodec __declspec(dllimport) #else ___ 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/rtpdec: attach producer reference time if available
This produces true wallclock time at rtp source instead of the local wallclock time at rtp client. --- libavformat/internal.h | 8 libavformat/rtpdec.c | 10 ++ libavformat/utils.c| 9 + 3 files changed, 27 insertions(+) diff --git a/libavformat/internal.h b/libavformat/internal.h index 17a6ab07d3..1e10cde00e 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -254,6 +254,14 @@ uint64_t ff_ntp_time(void); */ uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us); +/** + * Parse the NTP time in micro seconds (since NTP epoch). + * + * @param ntp_ts NTP time stamp formatted as per the RFC-5905. + * @return the time in micro seconds (since NTP epoch) + */ +uint64_t ff_parse_ntp_time(uint64_t ntp_ts); + /** * Append the media-specific SDP fragment for the media stream c * to the buffer buff. diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 3d5b200099..3e5f280f2f 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -23,6 +23,7 @@ #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "libavutil/time.h" +#include "libavcodec/packet_internal.h" #include "avformat.h" #include "network.h" @@ -30,6 +31,7 @@ #include "url.h" #include "rtpdec.h" #include "rtpdec_formats.h" +#include "internal.h" #define MIN_FEEDBACK_INTERVAL 20 /* 200 ms in us */ @@ -594,6 +596,14 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam if (timestamp == RTP_NOTS_VALUE) return; +if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) { +uint64_t prft_us = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US + + timestamp - s->last_rtcp_timestamp; +if (ff_side_data_set_prft(pkt, prft_us) < 0) { +av_log(s->ic, AV_LOG_WARNING, "rtpdec: failed to set prft"); +} +} + if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE && s->ic->nb_streams > 1) { int64_t addend; int delta_timestamp; diff --git a/libavformat/utils.c b/libavformat/utils.c index 7e5767ec60..569922beaf 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4734,6 +4734,15 @@ uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us) return ntp_ts; } +uint64_t ff_parse_ntp_time(uint64_t ntp_ts) +{ +uint64_t sec = ntp_ts >> 32; +uint64_t frac_part = ntp_ts & 0xULL; +uint64_t usec = (frac_part * 100) / 0xULL; + +return (sec * 100) + usec; +} + int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) { const char *p; -- 2.25.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/utils: Preserve AV_PKT_FLAG_CORRUPT
Preserve AV_PKT_FLAG_CORRUPT so the caller can decide whether to drop the packet. --- libavformat/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index a73f944e6e..0dc978e3d2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1494,7 +1494,8 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, out_pkt->pts = st->parser->pts; out_pkt->dts = st->parser->dts; out_pkt->pos = st->parser->pos; -out_pkt->flags |= pkt->flags & AV_PKT_FLAG_DISCARD; +out_pkt->flags |= pkt->flags & (AV_PKT_FLAG_CORRUPT | + AV_PKT_FLAG_DISCARD); if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW) out_pkt->pos = st->parser->frame_offset; -- 2.26.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avcodec/adpcm_ima_cunning: support stereo
On 16/3/21 4:22 pm, Zane van Iperen wrote: Changes the sample format to S16P, but was only ever mono so it affects nothing. Signed-off-by: Zane van Iperen --- libavcodec/adpcm.c | 11 +++ tests/fate/adpcm.mak | 18 +- 2 files changed, 16 insertions(+), 13 deletions(-) Will apply series (+suggested fixes) in a few days if no objections. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/5] Fix printf specifiers for variables that will be switched to size_t
Signed-off-by: Andreas Rheinhardt --- There is btw an instance in ffprobe where a variable will have to be switched to size_t when doing the bump. Hopefully it won't be forgotten. libavcodec/decode.c| 5 + libavcodec/mpeg12enc.c | 5 + libavcodec/mscc.c | 5 + libavfilter/af_ashowinfo.c | 5 + libavfilter/vf_showinfo.c | 15 +++ libavformat/dump.c | 5 + libavformat/framecrcenc.c | 7 ++- libavformat/hashenc.c | 9 +++-- libavformat/matroskaenc.c | 3 ++- libavformat/webvttdec.c| 2 +- libavformat/webvttenc.c| 18 ++ 11 files changed, 70 insertions(+), 9 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index efa8a9ac8d..74e0d0679e 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -2061,7 +2061,12 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) memcpy(dst, pal, AVPALETTE_SIZE); return 1; } else if (pal) { +#if FF_API_BUFFER_SIZE_T av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); +#else +av_log(logctx, AV_LOG_ERROR, + "Palette size %"SIZE_SPECIFIER" is wrong\n", size); +#endif } return 0; } diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index a05c2db6cb..1bc733aff0 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -574,8 +574,13 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) put_bits(>pb, 8, 0xff); // marker_bits } else { av_log(s->avctx, AV_LOG_WARNING, +#if FF_API_BUFFER_SIZE_T "Warning Closed Caption size (%d) can not exceed 93 bytes " "and must be a multiple of 3\n", side_data->size); +#else +"Closed Caption size (%"SIZE_SPECIFIER") can not exceed " +"93 bytes and must be a multiple of 3\n", side_data->size); +#endif } } } diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c index fe02649623..4cec26f5b2 100644 --- a/libavcodec/mscc.c +++ b/libavcodec/mscc.c @@ -160,7 +160,12 @@ static int decode_frame(AVCodecContext *avctx, for (j = 0; j < 256; j++) s->pal[j] = 0xFF00 | AV_RL32(pal + j * 4); } else if (pal) { +#if FF_API_BUFFER_SIZE_T av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); +#else +av_log(avctx, AV_LOG_ERROR, + "Palette size %"SIZE_SPECIFIER" is wrong\n", size); +#endif } memcpy(frame->data[1], s->pal, AVPALETTE_SIZE); } diff --git a/libavfilter/af_ashowinfo.c b/libavfilter/af_ashowinfo.c index 9046e8d84a..0e84bd8d65 100644 --- a/libavfilter/af_ashowinfo.c +++ b/libavfilter/af_ashowinfo.c @@ -170,7 +170,12 @@ static void dump_audio_service_type(AVFilterContext *ctx, AVFrameSideData *sd) static void dump_unknown(AVFilterContext *ctx, AVFrameSideData *sd) { +#if FF_API_BUFFER_SIZE_T av_log(ctx, AV_LOG_INFO, "unknown side data type: %d, size %d bytes", sd->type, sd->size); +#else +av_log(ctx, AV_LOG_INFO, "unknown side data type: %d, size " + "%"SIZE_SPECIFIER" bytes", sd->type, sd->size); +#endif } static int filter_frame(AVFilterLink *inlink, AVFrame *buf) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 6208892005..bfcd5ebf72 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -314,7 +314,12 @@ static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSi int i; if (sd->size < uuid_size) { +#if FF_API_BUFFER_SIZE_T av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))\n", sd->size, uuid_size); +#else +av_log(ctx, AV_LOG_ERROR, "invalid data(%"SIZE_SPECIFIER" < " + "UUID(%d-bytes))\n", sd->size, uuid_size); +#endif return; } @@ -472,7 +477,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) av_log(ctx, AV_LOG_INFO, "pan/scan"); break; case AV_FRAME_DATA_A53_CC: +#if FF_API_BUFFER_SIZE_T av_log(ctx, AV_LOG_INFO, "A/53 closed captions (%d bytes)", sd->size); +#else +av_log(ctx, AV_LOG_INFO, "A/53 closed captions (%"SIZE_SPECIFIER" bytes)", + sd->size); +#endif break; case AV_FRAME_DATA_SPHERICAL: dump_spherical(ctx, frame, sd); @@ -516,8 +526,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) dump_sei_unregistered_metadata(ctx, sd); break; default: +#if FF_API_BUFFER_SIZE_T av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)\n", sd->type, sd->size); +#else +av_log(ctx, AV_LOG_WARNING, "unknown side data type %d " + "(%"SIZE_SPECIFIER" bytes)\n", sd->type, sd->size); +#endif
[FFmpeg-devel] [PATCH 4/5] avformat/matroskaenc: Check WebVTT subtitles for overflow
The destination here is an dynamic buffer which is restricted to INT_MAX, so check for that. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 5d8d4cd646..4931988efd 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2133,7 +2133,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac mkv_track *track = >tracks[pkt->stream_index]; ebml_master blockgroup; buffer_size_t id_size, settings_size; -int size; +int size = pkt->size + 2; const char *id, *settings; int64_t ts = track->write_dts ? pkt->dts : pkt->pts; const int flags = 0; @@ -2141,12 +2141,17 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER, _size); id = id ? id : ""; +if (id_size > INT_MAX - size) +return AVERROR(ERANGE); +size += id_size; settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS, _size); settings = settings ? settings : ""; +if (settings_size > INT_MAX - size) +return AVERROR(ERANGE); -size = id_size + 1 + settings_size + 1 + pkt->size; +size += settings_size; /* The following string is identical to the one in mkv_write_block so that * only one copy needs to exist in binaries. */ @@ -2170,7 +2175,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, pkt->duration); end_ebml_master(pb, blockgroup); -return pkt->duration; +return 0; } static int mkv_end_cluster(AVFormatContext *s) @@ -2341,7 +2346,9 @@ static int mkv_write_packet_internal(AVFormatContext *s, const AVPacket *pkt) } } else { if (par->codec_id == AV_CODEC_ID_WEBVTT) { -duration = mkv_write_vtt_blocks(s, pb, pkt); +ret = mkv_write_vtt_blocks(s, pb, pkt); +if (ret < 0) +return ret; } else { ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt->size, -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/5] avcodec: Factor updating palette out
Because the properties of frames returned from ff_get/reget_buffer are not reset at all, lots of returned frames had palette_has_changed wrongly set to 1. This has been changed, too. Signed-off-by: Andreas Rheinhardt --- libavcodec/8bps.c | 11 +-- libavcodec/cinepak.c| 9 + libavcodec/decode.c | 14 ++ libavcodec/gdv.c| 5 + libavcodec/idcinvideo.c | 9 + libavcodec/imx.c| 5 + libavcodec/internal.h | 9 + libavcodec/interplayvideo.c | 9 + libavcodec/kmvc.c | 8 +--- libavcodec/msrle.c | 11 ++- libavcodec/msvideo1.c | 10 +- libavcodec/qpeg.c | 9 + libavcodec/qtrle.c | 10 +- libavcodec/rawdec.c | 13 ++--- libavcodec/rscc.c | 13 ++--- libavcodec/smc.c| 9 + libavcodec/tscc.c | 10 +- 17 files changed, 41 insertions(+), 123 deletions(-) diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 53e939d35d..9d19e21342 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -122,16 +122,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, } if (avctx->bits_per_coded_sample <= 8) { -buffer_size_t size; -const uint8_t *pal = av_packet_get_side_data(avpkt, - AV_PKT_DATA_PALETTE, - ); -if (pal && size == AVPALETTE_SIZE) { -frame->palette_has_changed = 1; -memcpy(c->pal, pal, AVPALETTE_SIZE); -} else if (pal) { -av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); -} +frame->palette_has_changed = ff_copy_palette(c->pal, avpkt, avctx); memcpy (frame->data[1], c->pal, AVPALETTE_SIZE); } diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index d70cb4b694..61e2991d04 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -477,14 +477,7 @@ static int cinepak_decode_frame(AVCodecContext *avctx, return ret; if (s->palette_video) { -buffer_size_t size; -const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, ); -if (pal && size == AVPALETTE_SIZE) { -s->frame->palette_has_changed = 1; -memcpy(s->pal, pal, AVPALETTE_SIZE); -} else if (pal) { -av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); -} +s->frame->palette_has_changed = ff_copy_palette(s->pal, avpkt, avctx); } if ((ret = cinepak_decode(s)) < 0) { diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 5a00aeedae..efa8a9ac8d 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -2051,3 +2051,17 @@ FF_ENABLE_DEPRECATION_WARNINGS return 0; } + +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) +{ +buffer_size_t size; +const void *pal = av_packet_get_side_data(src, AV_PKT_DATA_PALETTE, ); + +if (pal && size == AVPALETTE_SIZE) { +memcpy(dst, pal, AVPALETTE_SIZE); +return 1; +} else if (pal) { +av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); +} +return 0; +} diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c index 860634c9ec..cda284a32a 100644 --- a/libavcodec/gdv.c +++ b/libavcodec/gdv.c @@ -462,8 +462,6 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data, PutByteContext *pb = >pb; AVFrame *frame = data; int ret, i; -buffer_size_t pal_size; -const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, _size); int compression; unsigned flags; uint8_t *dst; @@ -479,8 +477,7 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; -if (pal && pal_size == AVPALETTE_SIZE) -memcpy(gdv->pal, pal, AVPALETTE_SIZE); +ff_copy_palette(gdv->pal, avpkt, avctx); if (compression < 2 && bytestream2_get_bytes_left(gb) < 256*3) return AVERROR_INVALIDDATA; diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c index 569191511f..02d5957bc7 100644 --- a/libavcodec/idcinvideo.c +++ b/libavcodec/idcinvideo.c @@ -214,8 +214,6 @@ static int idcin_decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IdcinContext *s = avctx->priv_data; -buffer_size_t pal_size; -const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, _size); AVFrame *frame = data; int ret; @@ -228,12 +226,7 @@ static int idcin_decode_frame(AVCodecContext *avctx, if (idcin_decode_vlcs(s, frame)) return AVERROR_INVALIDDATA; -if (pal && pal_size == AVPALETTE_SIZE) { -frame->palette_has_changed = 1; -memcpy(s->pal, pal, AVPALETTE_SIZE); -
[FFmpeg-devel] [PATCH 2/5] avcodec/packet: Also change av_packet_pack/unpack_dictionary to size_t
These are auxiliary side-data functions, so they should have been switched to size_t in d79e0fe65c51491f9bf8a470bbe36fb09f3e1280, but this has been forgotten. Signed-off-by: Andreas Rheinhardt --- libavcodec/avpacket.c| 13 + libavcodec/packet.h | 10 +- libavdevice/decklink_dec.cpp | 2 +- libavdevice/lavfi.c | 2 +- libavformat/concatdec.c | 2 +- libavformat/img2dec.c| 3 ++- libavformat/oggdec.h | 2 +- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 8f0850fb00..b5bac5c5f2 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -507,7 +507,11 @@ int av_packet_split_side_data(AVPacket *pkt){ } #endif +#if FF_API_BUFFER_SIZE_T uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) +#else +uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size) +#endif { uint8_t *data = NULL; *size = 0; @@ -526,7 +530,11 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) if (pass) memcpy(data + total_length, str, len); +#if FF_API_BUFFER_SIZE_T else if (len > INT_MAX - total_length) +#else +else if (len > SIZE_MAX - total_length) +#endif return NULL; total_length += len; } @@ -542,7 +550,12 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) return data; } +#if FF_API_BUFFER_SIZE_T int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) +#else +int av_packet_unpack_dictionary(const uint8_t *data, size_t size, +AVDictionary **dict) +#endif { const uint8_t *end; int ret; diff --git a/libavcodec/packet.h b/libavcodec/packet.h index da4377e09f..ca18ae631f 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -647,7 +647,11 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type); * @param size pointer to store the size of the returned data * @return pointer to data if successful, NULL otherwise */ +#if FF_API_BUFFER_SIZE_T uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); +#else +uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size); +#endif /** * Unpack a dictionary from side_data. * @@ -656,8 +660,12 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); * @param dict the metadata storage dictionary * @return 0 on success, < 0 on failure */ +#if FF_API_BUFFER_SIZE_T int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict); - +#else +int av_packet_unpack_dictionary(const uint8_t *data, size_t size, +AVDictionary **dict); +#endif /** * Convenience function to free all the side data stored. diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 40c3dae968..79d96cd620 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -922,7 +922,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( const char *tc = av_timecode_make_string(, tcstr, 0); if (tc) { AVDictionary* metadata_dict = NULL; -int metadata_len; uint8_t* packed_metadata; if (av_cmp_q(ctx->video_st->r_frame_rate, av_make_q(60, 1)) < 1) { @@ -937,6 +936,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( } if (av_dict_set(_dict, "timecode", tc, 0) >= 0) { +buffer_size_t metadata_len; packed_metadata = av_packet_pack_dictionary(metadata_dict, _len); av_dict_free(_dict); if (packed_metadata) { diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 94ad03268a..fdadff3f7f 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -446,7 +446,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) frame_metadata = frame->metadata; if (frame_metadata) { -int size; +buffer_size_t size; uint8_t *metadata = av_packet_pack_dictionary(frame_metadata, ); if (!metadata) { diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 6d5b9914f9..32d4a99010 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -626,7 +626,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, >time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, >time_base)); if (cat->cur_file->metadata) { -int metadata_len; +buffer_size_t metadata_len; char* packed_metadata = av_packet_pack_dictionary(cat->cur_file->metadata, _len); if
[FFmpeg-devel] [PATCH 1/5] avcodec/avpacket: Improve overflow checks when packing dictionary
Also avoid reallocations. Signed-off-by: Andreas Rheinhardt --- libavcodec/avpacket.c | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 6840688b15..8f0850fb00 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -509,37 +509,37 @@ int av_packet_split_side_data(AVPacket *pkt){ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) { -AVDictionaryEntry *t = NULL; uint8_t *data = NULL; *size = 0; if (!dict) return NULL; -while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) { -const size_t keylen = strlen(t->key); -const size_t valuelen = strlen(t->value); -const size_t new_size = *size + keylen + 1 + valuelen + 1; -uint8_t *const new_data = av_realloc(data, new_size); +for (int pass = 0; pass < 2; pass++) { +const AVDictionaryEntry *t = NULL; +size_t total_length = 0; -if (!new_data) -goto fail; -data = new_data; -if (new_size > INT_MAX) -goto fail; - -memcpy(data + *size, t->key, keylen + 1); -memcpy(data + *size + keylen + 1, t->value, valuelen + 1); +while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) { +for (int i = 0; i < 2; i++) { +const char *str = i ? t->value : t->key; +const size_t len = strlen(str) + 1; -*size = new_size; +if (pass) +memcpy(data + total_length, str, len); +else if (len > INT_MAX - total_length) +return NULL; +total_length += len; +} +} +if (pass) +break; +data = av_malloc(total_length); +if (!data) +return NULL; +*size = total_length; } return data; - -fail: -av_freep(); -*size = 0; -return NULL; } int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avformat/mov: Check sample size for overflow in mov_parse_stsd_audio()
Fixes: signed integer overflow: 2 * 1914708000 cannot be represented in type 'int' Fixes: 31639/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6303428239294464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index f9c4dbe5d4..3729e7d0bb 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2263,7 +2263,7 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, } bits_per_sample = av_get_bits_per_sample(st->codecpar->codec_id); -if (bits_per_sample) { +if (bits_per_sample && (bits_per_sample >> 3) * (uint64_t)st->codecpar->channels <= INT_MAX) { st->codecpar->bits_per_coded_sample = bits_per_sample; sc->sample_size = (bits_per_sample >> 3) * st->codecpar->channels; } -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avcodec/sga: Check for array end in lzss_decompress()
Fixes: out of array access Fixes: 31640/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGA_fuzzer-5630883286614016 Fixes: 31619/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGA_fuzzer-5176667708456960 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/sga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/sga.c b/libavcodec/sga.c index 00752a5843..881f3fa6b2 100644 --- a/libavcodec/sga.c +++ b/libavcodec/sga.c @@ -232,7 +232,7 @@ static int lzss_decompress(AVCodecContext *avctx, if (offset <= 0) offset = 1; -if (oi < offset) +if (oi < offset || oi + count * 2 > dst_size ) return AVERROR_INVALIDDATA; for (int j = 0; j < count * 2; j++) { dst[oi] = dst[oi - offset]; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avformat/mpc8: check for size overflow in mpc8_get_chunk_header()
Fixes: signed integer overflow: -9223372036854775760 - 50 cannot be represented in type 'long' Fixes: 31673/clusterfuzz-testcase-minimized-ffmpeg_dem_MPC8_fuzzer-580134751869337 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mpc8.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index ff7da2ef55..b12a417f63 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -127,7 +127,11 @@ static void mpc8_get_chunk_header(AVIOContext *pb, int *tag, int64_t *size) pos = avio_tell(pb); *tag = avio_rl16(pb); *size = ffio_read_varlen(pb); -*size -= avio_tell(pb) - pos; +pos -= avio_tell(pb); +if (av_sat_add64(*size, pos) != (uint64_t)*size + pos) { +*size = -1; +} else +*size += pos; } static void mpc8_parse_seektable(AVFormatContext *s, int64_t off) -- 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] LZSS
Hi We seem to have 3 implementations of LZSS, i noticed while fixing a bug in one libavcodec/dsicinvideo.c:static int cin_decode_lzss(const unsigned char *src, int src_size, libavcodec/midivid.c:static ptrdiff_t lzss_uncompress(MidiVidContext *s, GetByteContext *gb, uint8_t *dst, unsigned int size) libavcodec/sga.c:static int lzss_decompress(AVCodecContext *avctx, maybe this can be factord somehow Thanks -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin 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 2/2] avformat: Make AVChapter.id an int64_t on next major bump
Andreas Rheinhardt: > 64 bits are needed in order to retain the uid values of Matroska > chapters; the type is kept signed because the semantics of NUT chapters > depend upon whether the id is > 0 or < 0. > > Signed-off-by: Andreas Rheinhardt > --- > Apologies for being so late. > > doc/APIchanges| 4 > libavformat/aadec.c | 2 +- > libavformat/avformat.h| 4 > libavformat/internal.h| 4 > libavformat/matroskaenc.c | 4 > libavformat/nutdec.c | 4 ++-- > libavformat/utils.c | 4 > libavformat/version.h | 5 - > 8 files changed, 27 insertions(+), 4 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index c0d955b1fa..8b93adebe1 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -15,6 +15,10 @@ libavutil: 2017-10-21 > > API changes, most recent first: > > +2021-03-16 - xx - lavf 58.75.100 - avformat.h > + AVChapter.id will be changed from int to int64_t > + on the next major version bump. > + > 2021-03-12 - xx - lavc 58.131.100 - avcodec.h codec.h >Add a get_encode_buffer callback to AVCodecContext, similar to >get_buffer2 but for encoders. > diff --git a/libavformat/aadec.c b/libavformat/aadec.c > index e88cdb89df..80ca2c12d7 100644 > --- a/libavformat/aadec.c > +++ b/libavformat/aadec.c > @@ -222,7 +222,7 @@ static int aa_read_header(AVFormatContext *s) > c->content_end = start + largest_size; > > while ((chapter_pos = avio_tell(pb)) >= 0 && chapter_pos < > c->content_end) { > -int chapter_idx = s->nb_chapters; > +unsigned chapter_idx = s->nb_chapters; > uint32_t chapter_size = avio_rb32(pb); > if (chapter_size == 0 || avio_feof(pb)) > break; > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index e3bd01ec7f..765bc3b6f5 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -1184,7 +1184,11 @@ typedef struct AVProgram { > change dynamically at runtime. */ > > typedef struct AVChapter { > +#if FF_API_CHAPTER_ID_INT > int id; ///< unique ID to identify the chapter > +#else > +int64_t id; ///< unique ID to identify the chapter > +#endif > AVRational time_base; ///< time base in which the start/end timestamps > are specified > int64_t start, end; ///< chapter start/end time in time_base units > AVDictionary *metadata; > diff --git a/libavformat/internal.h b/libavformat/internal.h > index 0ffdc87b6a..df4918e318 100644 > --- a/libavformat/internal.h > +++ b/libavformat/internal.h > @@ -554,7 +554,11 @@ void ff_configure_buffers_for_index(AVFormatContext *s, > int64_t time_tolerance); > * > * @return AVChapter or NULL on error > */ > +#if FF_API_CHAPTER_ID_INT > AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational > time_base, > +#else > +AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational > time_base, > +#endif >int64_t start, int64_t end, const char *title); > > /** > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index 8f29d64e72..02e171593e 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -1669,7 +1669,11 @@ static int mkv_write_chapters(AVFormatContext *s) > 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 FF_API_CHAPTER_ID_INT > uint64_t uid = create_new_ids ? i + 1ULL : (uint32_t)c->id; > +#else > +uint64_t uid = create_new_ids ? i + 1ULL : c->id; > +#endif > if (chapterstart < 0 || chapterstart > chapterend || chapterend < 0) > { > av_log(s, AV_LOG_ERROR, > "Invalid chapter start (%"PRId64") or end (%"PRId64").\n", > diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c > index ebb062377d..d1f3496990 100644 > --- a/libavformat/nutdec.c > +++ b/libavformat/nutdec.c > @@ -489,8 +489,8 @@ static int decode_info_header(NUTContext *nut) > AVIOContext *bc= s->pb; > uint64_t tmp, chapter_start, chapter_len; > unsigned int stream_id_plus1, count; > -int chapter_id, i, ret = 0; > -int64_t value, end; > +int i, ret = 0; > +int64_t chapter_id, value, end; > char name[256], str_value[1024], type_str[256]; > const char *type; > int *event_flags= NULL; > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 8573117694..8fb5dbbf9d 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -4611,7 +4611,11 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) > return program; > } > > +#if FF_API_CHAPTER_ID_INT > AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational > time_base, > +#else > +AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t
Re: [FFmpeg-devel] FFmpeg 4.4
On 3/13/2021 8:29 AM, Michael Niedermayer wrote: On Wed, Mar 10, 2021 at 10:06:49AM -0300, James Almer wrote: On 3/10/2021 7:37 AM, Michael Niedermayer wrote: On Tue, Mar 09, 2021 at 05:55:55PM -0300, James Almer wrote: On 3/9/2021 5:47 PM, Michael Niedermayer wrote: Hi all I will branch release/4.4 soon then like always leave some time for testing, bugfixes, ... and then make FFmeg 4.4 from release/4.4, its too long since 4.3 Thanks I have three API changes/additions/deprecations on the ml, some for months now, that i want in 4.4 in order for them to be present in the last release using the current major library versions. This is so users have a good amount of time to notice them and adapt their code. It's not be as nice if they start noticing any new deprecations introduced today in a release made several months from now. These are "deprecate av_init_packet() and sizeof(AVPacket) as part of the ABI", It seems this is still missing "avutil/buffer: change public function and struct size parameter types to size_t", and I see several 4 "size parameter type to size_t" commits in git now so these seem applied "avcodec: add a get_encoder_buffer() callback to AVCodecContext". This was applied as 6e7e3a3820f0888ff92d6be44f40ff733bcce874 So it seems only one blocker is left for making the release branch If thats incorrect someone please correct me! thx All three sets were pushed, so nothing else from me. 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".
[FFmpeg-devel] [PATCH 3/3] avcodec/pngdec: Improve decoding text chunks
By checking immediately whether the first allocation was successfull one can simplify the cleanup code in case of errors. Signed-off-by: Andreas Rheinhardt --- libavcodec/pngdec.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 21e79a24a7..813f16692c 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -539,12 +539,13 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, text_len = data_end - data; } -kw_utf8 = iso88591_to_utf8(keyword, keyword_end - keyword); txt_utf8 = iso88591_to_utf8(data, text_len); if (compressed) av_bprint_finalize(, NULL); -if (!(kw_utf8 && txt_utf8)) { -av_free(kw_utf8); +if (!txt_utf8) +return AVERROR(ENOMEM); +kw_utf8 = iso88591_to_utf8(keyword, keyword_end - keyword); +if (!kw_utf8) { av_free(txt_utf8); return AVERROR(ENOMEM); } -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avcodec/pngdec: Don't use AVBPrint where inappropriate
Signed-off-by: Andreas Rheinhardt --- libavcodec/pngdec.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 6b9fdf5a22..21e79a24a7 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1338,17 +1338,13 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, break; } case MKTAG('g', 'A', 'M', 'A'): { -AVBPrint bp; -char *gamma_str; +char gamma_str[18]; int num = bytestream2_get_be32(>gb); -av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED); -av_bprintf(, "%i/%i", num, 10); -ret = av_bprint_finalize(, _str); -if (ret < 0) -return ret; +snprintf(gamma_str, sizeof(gamma_str), "%i/10", num); -av_dict_set(>metadata, "gamma", gamma_str, AV_DICT_DONT_STRDUP_VAL); +if ((ret = av_dict_set(>metadata, "gamma", gamma_str, 0)) < 0) +return ret; bytestream2_skip(>gb, 4); /* crc */ break; -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avcodec/pngdec: Use internal AVBPrint string when parsing chunks
One saves an allocation in case the string fits into the buffer. Signed-off-by: Andreas Rheinhardt --- 5663301560d77486c7f7c03c1aa5f542fab23c24 caused a regression that makes some png files lose their metadata, because decode_idat_chunk() unrefs the frame that the metadata has been attached to. I therefore tested these commits with the aforementioned commit reverted. libavcodec/pngdec.c | 27 ++- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index a5a71ef161..6b9fdf5a22 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -517,7 +517,7 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, const uint8_t *data_end= data + length; const uint8_t *keyword = data; const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword); -uint8_t *kw_utf8 = NULL, *text, *txt_utf8 = NULL; +uint8_t *kw_utf8 = NULL, *txt_utf8 = NULL; unsigned text_len; AVBPrint bp; @@ -533,19 +533,16 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, return AVERROR_INVALIDDATA; if ((ret = decode_zbuf(, data, data_end)) < 0) return ret; +data = bp.str; text_len = bp.len; -ret = av_bprint_finalize(, (char **)); -if (ret < 0) -return ret; } else { -text = (uint8_t *)data; -text_len = data_end - text; +text_len = data_end - data; } kw_utf8 = iso88591_to_utf8(keyword, keyword_end - keyword); -txt_utf8 = iso88591_to_utf8(text, text_len); -if (text != data) -av_free(text); +txt_utf8 = iso88591_to_utf8(data, text_len); +if (compressed) +av_bprint_finalize(, NULL); if (!(kw_utf8 && txt_utf8)) { av_free(kw_utf8); av_free(txt_utf8); @@ -851,7 +848,7 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s, static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) { int ret, cnt = 0; -uint8_t *data, profile_name[82]; +uint8_t profile_name[82]; AVBPrint bp; AVFrameSideData *sd; @@ -873,19 +870,15 @@ static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) if ((ret = decode_zbuf(, s->gb.buffer, s->gb.buffer + length)) < 0) return ret; -ret = av_bprint_finalize(, (char **)); -if (ret < 0) -return ret; - sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len); if (!sd) { -av_free(data); +av_bprint_finalize(, NULL); return AVERROR(ENOMEM); } +memcpy(sd->data, bp.str, bp.len); +av_bprint_finalize(, NULL); av_dict_set(>metadata, "name", profile_name, 0); -memcpy(sd->data, data, bp.len); -av_free(data); /* ICC compressed data and CRC */ bytestream2_skip(>gb, length + 4); -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec: move core AVCodecContext functions from util.c to a new file
Signed-off-by: James Almer --- Makefile | 2 +- libavcodec/Makefile | 1 + libavcodec/avcodec.c | 845 +++ libavcodec/utils.c | 828 +- 4 files changed, 850 insertions(+), 826 deletions(-) create mode 100644 libavcodec/avcodec.c diff --git a/Makefile b/Makefile index 977ad69965..7e9d8b08c3 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ include $(SRC_PATH)/fftools/Makefile include $(SRC_PATH)/doc/Makefile include $(SRC_PATH)/doc/examples/Makefile -libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h +libavcodec/avcodec.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h $(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF) ifeq ($(STRIPTYPE),direct) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index baf712129f..33a280cf69 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -29,6 +29,7 @@ HEADERS = ac3_parser.h \ OBJS = ac3_parser.o \ adts_parser.o\ allcodecs.o \ + avcodec.o\ avdct.o \ avpacket.o \ avpicture.o \ diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c new file mode 100644 index 00..fd3bdf813b --- /dev/null +++ b/libavcodec/avcodec.c @@ -0,0 +1,845 @@ +/* + * Core functions for libavcodec + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Core functions for libavcodec + */ + +#include "config.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/imgutils.h" +#include "libavutil/mem.h" +#include "libavutil/opt.h" +#include "libavutil/thread.h" +#include "avcodec.h" +#include "decode.h" +#include "encode.h" +#include "frame_thread_encoder.h" +#include "internal.h" +#include "thread.h" +#if CONFIG_ICONV +# include +#endif + +#include "libavutil/ffversion.h" +const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; + +unsigned avcodec_version(void) +{ +av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563); +av_assert0(AV_CODEC_ID_ADPCM_G722==69660); +av_assert0(AV_CODEC_ID_SRT==94216); +av_assert0(LIBAVCODEC_VERSION_MICRO >= 100); + +return LIBAVCODEC_VERSION_INT; +} + +const char *avcodec_configuration(void) +{ +return FFMPEG_CONFIGURATION; +} + +const char *avcodec_license(void) +{ +#define LICENSE_PREFIX "libavcodec license: " +return _PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1]; +} + +int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size) +{ +int i; + +for (i = 0; i < count; i++) { +int r = func(c, (char *)arg + i * size); +if (ret) +ret[i] = r; +} +emms_c(); +return 0; +} + +int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count) +{ +int i; + +for (i = 0; i < count; i++) { +int r = func(c, arg, i, 0); +if (ret) +ret[i] = r; +} +emms_c(); +return 0; +} + +static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; + +static void lock_avcodec(const AVCodec *codec) +{ +if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) +ff_mutex_lock(_mutex); +} + +static void unlock_avcodec(const AVCodec *codec) +{ +if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) +ff_mutex_unlock(_mutex); +} + +#if FF_API_LOCKMGR +int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) +{
[FFmpeg-devel] [PATCH 1/2] avcodec: move AVCodecParameters related functions from util.c to a new file
Signed-off-by: James Almer --- libavcodec/Makefile| 1 + libavcodec/codec_par.c | 202 + libavcodec/utils.c | 173 --- 3 files changed, 203 insertions(+), 173 deletions(-) create mode 100644 libavcodec/codec_par.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 81cc16471b..baf712129f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -37,6 +37,7 @@ OBJS = ac3_parser.o \ bitstream_filters.o \ bsf.o\ codec_desc.o \ + codec_par.o \ d3d11va.o\ decode.o \ dirac.o \ diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c new file mode 100644 index 00..1a5168a04b --- /dev/null +++ b/libavcodec/codec_par.c @@ -0,0 +1,202 @@ +/* + * AVCodecParameters functions for libavcodec + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * AVCodecParameters functions for libavcodec. + */ + +#include +#include "libavutil/mem.h" +#include "avcodec.h" +#include "codec_par.h" + +static void codec_parameters_reset(AVCodecParameters *par) +{ +av_freep(>extradata); + +memset(par, 0, sizeof(*par)); + +par->codec_type = AVMEDIA_TYPE_UNKNOWN; +par->codec_id= AV_CODEC_ID_NONE; +par->format = -1; +par->field_order = AV_FIELD_UNKNOWN; +par->color_range = AVCOL_RANGE_UNSPECIFIED; +par->color_primaries = AVCOL_PRI_UNSPECIFIED; +par->color_trc = AVCOL_TRC_UNSPECIFIED; +par->color_space = AVCOL_SPC_UNSPECIFIED; +par->chroma_location = AVCHROMA_LOC_UNSPECIFIED; +par->sample_aspect_ratio = (AVRational){ 0, 1 }; +par->profile = FF_PROFILE_UNKNOWN; +par->level = FF_LEVEL_UNKNOWN; +} + +AVCodecParameters *avcodec_parameters_alloc(void) +{ +AVCodecParameters *par = av_mallocz(sizeof(*par)); + +if (!par) +return NULL; +codec_parameters_reset(par); +return par; +} + +void avcodec_parameters_free(AVCodecParameters **ppar) +{ +AVCodecParameters *par = *ppar; + +if (!par) +return; +codec_parameters_reset(par); + +av_freep(ppar); +} + +int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src) +{ +codec_parameters_reset(dst); +memcpy(dst, src, sizeof(*dst)); + +dst->extradata = NULL; +dst->extradata_size = 0; +if (src->extradata) { +dst->extradata = av_mallocz(src->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); +if (!dst->extradata) +return AVERROR(ENOMEM); +memcpy(dst->extradata, src->extradata, src->extradata_size); +dst->extradata_size = src->extradata_size; +} + +return 0; +} + +int avcodec_parameters_from_context(AVCodecParameters *par, +const AVCodecContext *codec) +{ +codec_parameters_reset(par); + +par->codec_type = codec->codec_type; +par->codec_id = codec->codec_id; +par->codec_tag = codec->codec_tag; + +par->bit_rate = codec->bit_rate; +par->bits_per_coded_sample = codec->bits_per_coded_sample; +par->bits_per_raw_sample = codec->bits_per_raw_sample; +par->profile = codec->profile; +par->level = codec->level; + +switch (par->codec_type) { +case AVMEDIA_TYPE_VIDEO: +par->format = codec->pix_fmt; +par->width = codec->width; +par->height = codec->height; +par->field_order = codec->field_order; +par->color_range = codec->color_range; +par->color_primaries = codec->color_primaries; +par->color_trc = codec->color_trc; +par->color_space =
Re: [FFmpeg-devel] [PATCH] avcodec/libdavs2: unbreak compilation failure
applied this one, since this broke my builds. smime.p7s Description: S/MIME Cryptographic 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] avcodec: add Actimagine VX video decoder
I found the origin of this color system. It was originally used with the first gba video paks (which used a way different codec). It is being described in this patent by Majesco (the 7th image, FIG. 4A and FIG. 4B): https://patents.google.com/patent/US7253819B1/en Later gba video paks seem to use the actimage vx format, so I guess there must have been a collaboration of some sort there. ___ 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/mov: Handle when we have an mfra box but have not read the full sidx for a fragment
On 15/03/2021 17:04, Derek Buitenhuis wrote: > Use the tfra timestamp if it is available and sidx timestamp is not. > > Fixes reading the entire file after seeking in a live-style DASH FMP4 > with an MFRA. > > This specifically fixes when use_mfra_for is set. > > Signed-off-by: Derek Buitenhuis > --- Will push later today if there are no objections. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec/speedhq: Width < 8 is not supported
Fixes: out of array access Fixes: 31733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-4704307963363328 Fixes: 31736/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-6190960292790272 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/speedhq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index 5861b7f6b5..711bcd66d7 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -498,7 +498,7 @@ static int speedhq_decode_frame(AVCodecContext *avctx, uint32_t second_field_offset; int ret; -if (buf_size < 4) +if (buf_size < 4 || avctx->width < 8) return AVERROR_INVALIDDATA; quality = buf[0]; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avformat/mov: Check offset addition for overflow
Fixes: signed integer overflow: 9223372036854775807 + 536870912 cannot be represented in type 'long' Fixes: 31678/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5614204619980800 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 23b0ead01e..aafe01fe26 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5047,6 +5047,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) int64_t stream_size = avio_size(pb); int64_t offset = av_sat_add64(avio_tell(pb), atom.size), pts, timestamp; uint8_t version, is_complete; +int64_t offadd; unsigned i, j, track_id, item_count; AVStream *st = NULL; AVStream *ref_st = NULL; @@ -5084,11 +5085,15 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (version == 0) { pts = avio_rb32(pb); -offset += avio_rb32(pb); +offadd= avio_rb32(pb); } else { pts = avio_rb64(pb); -offset += avio_rb64(pb); +offadd= avio_rb64(pb); } +if (av_sat_add64(offset, offadd) != offset + (uint64_t)offadd) +return AVERROR_INVALIDDATA; + +offset += (uint64_t)offadd; avio_rb16(pb); // reserved @@ -5111,6 +5116,8 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (frag_stream_info) frag_stream_info->sidx_pts = timestamp; +if (av_sat_add64(offset, size) != offset + size) +return AVERROR_INVALIDDATA; offset += size; pts += duration; } -- 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".