Re: [FFmpeg-devel] [PATCH 4/6] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"
Quoting Paul B Mahol (2021-02-16 21:57:47) > Do you have actual proof for such claims? The burden of proof is on you here - you are supposed to prove that your commit fixes something. And when I asked you about details, you couldn't even tell me what the bug was, much less why would switching the order of allocations be the correct fix for it. > > There is no point in reverting commit if that commit fixed some behavior. It didn't fix anything though. Before your commit, frame 69 of the sample in #9017 is almost black with 1 thread and looks okay with 2 threads. After your commit, it is almost black in both cases. So your commit made it consistently wrong. This shows up in my tests and is also supported by the last comment in https://trac.ffmpeg.org/ticket/9017 Feel free to test it yourself. -- 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 01/19] fate/matroska: Add test for mastering display metadata
The FATE suite already contains a file containing mastering display and content light level metadata: Meridian-Apple_ProResProxy-HDR10.mxf This file is used to test both the Matroska muxer and demuxer. Signed-off-by: Andreas Rheinhardt --- tests/fate/matroska.mak | 15 +++ .../fate/matroska-mastering-display-metadata | 97 +++ 2 files changed, 112 insertions(+) create mode 100644 tests/ref/fate/matroska-mastering-display-metadata diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index 2ce08f6c77..be68082c21 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -75,6 +75,21 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER MATROSKA_MUXER \ += fate-matroska-spherical-mono-remux fate-matroska-spherical-mono-remux: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/spherical.mkv matroska "-map 0 -map 0 -c copy -disposition:0 -default+forced -disposition:1 -default -default_mode passthrough -color_primaries:1 bt709 -color_trc:1 smpte170m -colorspace:1 bt2020c -color_range:1 pc" "-map 0 -c copy -t 0" "" "-show_entries stream_side_data_list:stream_disposition=default,forced:stream=color_range,color_space,color_primaries,color_transfer" +# The input file of the following test contains Content Light Level as well as +# Mastering Display Metadata and so this test tests correct muxing and demuxing +# of these. It furthermore also tests that this data is correctly propagated +# when reencoding (here to ffv1). +# Both input audio tracks are completely zero, so the noise bsf is used +# to make this test interesting. +FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MXF_DEMUXER\ +PRORES_DECODER PCM_S24LE_DECODER \ +FFV1_ENCODER ARESAMPLE_FILTER\ +PCM_S16BE_ENCODER NOISE_BSF \ +MATROSKA_MUXER MATROSKA_DEMUXER \ +FRAMECRC_MUXER PIPE_PROTOCOL)\ + += fate-matroska-mastering-display-metadata +fate-matroska-mastering-display-metadata: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf matroska "-map 0 -map 0:0 -c:v:0 copy -c:v:1 ffv1 -c:a:0 copy -bsf:a:0 noise=amount=3 -filter:a:1 aresample -c:a:1 pcm_s16be -bsf:a:1 noise=dropamount=4" "-map 0 -c copy" "" "-show_entries stream_side_data_list:stream=index,codec_name" + FATE_MATROSKA_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER) += fate-matroska-spherical-mono fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream_side_data_list -select_streams v -v 0 $(TARGET_SAMPLES)/mkv/spherical.mkv diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata new file mode 100644 index 00..4c7469caba --- /dev/null +++ b/tests/ref/fate/matroska-mastering-display-metadata @@ -0,0 +1,97 @@ +abdf9fa02f44f48a45ba48074cb1d0fe *tests/data/fate/matroska-mastering-display-metadata.matroska +1669691 tests/data/fate/matroska-mastering-display-metadata.matroska +#extradata 0:4, 0x040901a3 +#extradata 3: 200, 0x506463a8 +#tb 0: 1/1000 +#media_type 0: video +#codec_id 0: prores +#dimensions 0: 1280x720 +#sar 0: 1/1 +#tb 1: 1/1000 +#media_type 1: audio +#codec_id 1: pcm_s24le +#sample_rate 1: 48000 +#channel_layout 1: 4 +#channel_layout_name 1: mono +#tb 2: 1/1000 +#media_type 2: audio +#codec_id 2: pcm_s16be +#sample_rate 2: 48000 +#channel_layout 2: 4 +#channel_layout_name 2: mono +#tb 3: 1/1000 +#media_type 3: video +#codec_id 3: ffv1 +#dimensions 3: 1280x720 +#sar 3: 1/1 +0, 0, 0, 16,57008, 0x43416399, S=2,8, 0x08e5014f, 88, 0xd65a04db +1, 0, 0, 16, 2403, 0xaa818522 +3, 0, 0, 16, 274117, 0xc439610f, S=2,8, 0x08e5014f, 88, 0xd65a04db +0, 17, 17, 16,57248, 0xa06cd7b5 +1, 17, 17, 16, 2403, 0xe1a991e5 +2, 17, 17, 16, 1602, 0x5d868171 +3, 17, 17, 16, 273691, 0x5a3b88a5, F=0x0 +0, 33, 33, 16,57200, 0x5623da10 +1, 33, 33, 16, 2400, 0x6650907f +2, 33, 33, 16, 1600, 0xa90f0044 +3, 33, 33, 16, 272987, 0x48c443e7, F=0x0 +0, 50, 50, 16,57152, 0x52d89d3f +1, 50, 50, 16, 2403, 0x43398a08 +2, 50, 50, 16, 1602, 0x3a350084 +3, 50, 50, 16, 271465, 0x251b9cbe, F=0x0 +0, 67, 67, 16,56960, 0x431d5189 +1, 67, 67, 16, 2403, 0x61cd96cb +2, 67, 67, 16, 1602, 0xd74800c6 +3, 67, 67,
[FFmpeg-devel] [PATCH 02/19] avformat/matroskadec: Allow to count the number of element occurences
Up until now, the generic EBML reader used by the Matroska demuxer did not have the capability to record whether an element was actually present or not; instead, in cases where it mattered one typically added an invalid default value and checked whether the value is valid (in which case it is guaranteed to be present). This worked pretty well so far, yet the EBML specifications have evolved: It is now legal to use zero-length elements for floats, ints, uints and strings (both ASCII and UTF-8); the value of these elements is the default value of the element (if it has one) or zero for scalar types and an empty string for strings. Furthermore, having a default value does no longer imply that the element may be presumed to be present (with its default value) if it is absent; this is only true if the element is mandatory, too. These rules are designed to allow size savings as follows: Consider the newly added FlagOriginal: It being zero means the track is not in its original language, it being one means it is. For backward compatibility reasons, neither of the two values may be inferred automatically in the absence of the element. But one can still save a byte when one wants to write the element with a value of zero, as one can write the integer with a length of zero: 0x55AE 80 instead of 0x55AE 81 00. In the former case, a parser has to infer the value of the element to be zero (which is the element's default value). When encountering an element with length zero, our parser always infers a value of zero (or an empty string); this is wrong for values with a different default value. It needs to infer the default value (or zero in its absence) and this precludes using an invalid default value for elements like FlagOriginal. Ergo one needs to be able to record whether an element is present or not by other means. This patch allows to use a simple counter for this. While just at it, some invalid and unnecessary default values have been removed (mastering metadata elements used default values of -1.0, despite these elements only being used if they are > 0). Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 309 -- 1 file changed, 163 insertions(+), 146 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 374831baa3..ceb054e8ab 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -95,9 +95,20 @@ typedef enum { EBML_TYPE_COUNT } EbmlType; +typedef struct CountedElement { +union { +uint64_t u; +int64_t i; +doublef; +char *s; +} el; +unsigned count; +} CountedElement; + typedef const struct EbmlSyntax { uint32_t id; -EbmlType type; +uint8_t type; +uint8_t is_counted; size_t list_elem_size; size_t data_offset; union { @@ -405,113 +416,113 @@ static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_colo matroska_blockadditions[2], matroska_blockgroup[8], matroska_cluster_parsing[8]; static EbmlSyntax ebml_header[] = { -{ EBML_ID_EBMLREADVERSION,EBML_UINT, 0, offsetof(Ebml, version), { .u = EBML_VERSION } }, -{ EBML_ID_EBMLMAXSIZELENGTH, EBML_UINT, 0, offsetof(Ebml, max_size), { .u = 8 } }, -{ EBML_ID_EBMLMAXIDLENGTH,EBML_UINT, 0, offsetof(Ebml, id_length), { .u = 4 } }, -{ EBML_ID_DOCTYPE,EBML_STR, 0, offsetof(Ebml, doctype), { .s = "(none)" } }, -{ EBML_ID_DOCTYPEREADVERSION, EBML_UINT, 0, offsetof(Ebml, doctype_version), { .u = 1 } }, +{ EBML_ID_EBMLREADVERSION,EBML_UINT, 0, 0, offsetof(Ebml, version), { .u = EBML_VERSION } }, +{ EBML_ID_EBMLMAXSIZELENGTH, EBML_UINT, 0, 0, offsetof(Ebml, max_size), { .u = 8 } }, +{ EBML_ID_EBMLMAXIDLENGTH,EBML_UINT, 0, 0, offsetof(Ebml, id_length), { .u = 4 } }, +{ EBML_ID_DOCTYPE,EBML_STR, 0, 0, offsetof(Ebml, doctype), { .s = "(none)" } }, +{ EBML_ID_DOCTYPEREADVERSION, EBML_UINT, 0, 0, offsetof(Ebml, doctype_version), { .u = 1 } }, { EBML_ID_EBMLVERSION,EBML_NONE }, { EBML_ID_DOCTYPEVERSION, EBML_NONE }, CHILD_OF(ebml_syntax) }; static EbmlSyntax ebml_syntax[] = { -{ EBML_ID_HEADER, EBML_NEST, 0, 0, { .n = ebml_header } }, +{ EBML_ID_HEADER, EBML_NEST, 0, 0, 0, { .n = ebml_header } }, { MATROSKA_ID_SEGMENT, EBML_STOP }, { 0 } }; static EbmlSyntax matroska_info[] = { -{ MATROSKA_ID_TIMECODESCALE, EBML_UINT, 0, offsetof(MatroskaDemuxContext, time_scale), { .u = 100 } }, -{ MATROSKA_ID_DURATION, EBML_FLOAT, 0, offsetof(MatroskaDemuxContext, duration) }, -{ MATROSKA_ID_TITLE, EBML_UTF8, 0, offsetof(MatroskaDemuxContext, title) }, +{ MATROSKA_ID_TIMECODESCALE, EBML_UINT, 0, 0, offsetof(MatroskaDemuxContext, time_scale), { .u = 100 } }, +{ MATROSKA_ID_DURATION, EBML_FLOAT, 0, 0,
[FFmpeg-devel] [PATCH 03/19] avformat/matroskadec: Check min_luminance more thoroughly
In the absence of an explicitly coded minimal luminance, the current code inferred it to be -1, an invalid value. Yet it did not check the value lateron at all, so that if a valid maximum luminance is encountered, but no minimal luminance, an invalid minimal luminance of -1 is exported. If an minimal luminance element with a negative value is present, it is exported, too. This can be simply fixed by adding a check for the value of the element. Yet given that a minimal luminance of zero Cd/m² is legal and can be coded with a length of zero, we must not use a fake default value to find out whether the element is present or not. Therefore this patch uses an explicit counter for it. While just at it, also check for max_luminance > min_luminance. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index ceb054e8ab..e6f4faa337 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -168,7 +168,7 @@ typedef struct MatroskaMasteringMeta { double white_x; double white_y; double max_luminance; -double min_luminance; +CountedElement min_luminance; } MatroskaMasteringMeta; typedef struct MatroskaTrackVideoColor { @@ -452,7 +452,7 @@ static EbmlSyntax matroska_mastering_meta[] = { { MATROSKA_ID_VIDEOCOLOR_BY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, b_y) }, { MATROSKA_ID_VIDEOCOLOR_WHITEX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, white_x) }, { MATROSKA_ID_VIDEOCOLOR_WHITEY, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, white_y) }, -{ MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, min_luminance), { .f=-1 } }, +{ MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN, EBML_FLOAT, 1, 0, offsetof(MatroskaMasteringMeta, min_luminance) }, { MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX, EBML_FLOAT, 0, 0, offsetof(MatroskaMasteringMeta, max_luminance) }, CHILD_OF(matroska_track_video_color) }; @@ -2110,7 +2110,10 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) { mastering_meta->g_x > 0 && mastering_meta->g_y > 0 && mastering_meta->b_x > 0 && mastering_meta->b_y > 0 && mastering_meta->white_x > 0 && mastering_meta->white_y > 0; -has_mastering_luminance = mastering_meta->max_luminance > 0; +has_mastering_luminance = mastering_meta->max_luminance > + mastering_meta->min_luminance.el.f && + mastering_meta->min_luminance.el.f >= 0 && + mastering_meta->min_luminance.count; if (color->matrix_coefficients != AVCOL_SPC_RESERVED) st->codecpar->color_space = color->matrix_coefficients; @@ -2169,7 +2172,7 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) { } if (has_mastering_luminance) { metadata->max_luminance = av_d2q(mastering_meta->max_luminance, INT_MAX); -metadata->min_luminance = av_d2q(mastering_meta->min_luminance, INT_MAX); +metadata->min_luminance = av_d2q(mastering_meta->min_luminance.el.f, INT_MAX); metadata->has_luminance = 1; } } -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 10/19] avformat/matroskaenc: Support FlagCommentary
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 786fa41cba..746c0b347a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1191,6 +1191,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, put_ebml_string(pb, MATROSKA_ID_CODECID, codec_id); } else { +if (st->disposition & AV_DISPOSITION_COMMENT) +put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGCOMMENTARY, 1); // look for a codec ID string specific to mkv to use, // if none are found, use AVI codes if (par->codec_id != AV_CODEC_ID_RAWVIDEO || par->codec_tag) { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 11/19] avformat/matroskadec: Support FlagOriginal
Needs a CountedElement in order to distinguish the case of the element not being present and the element being present with a value of zero. Signed-off-by: Andreas Rheinhardt --- libavformat/matroska.h| 1 + libavformat/matroskadec.c | 7 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 191c4f6149..8ab87eff20 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -100,6 +100,7 @@ #define MATROSKA_ID_TRACKFLAGDEFAULT 0x88 #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA #define MATROSKA_ID_TRACKFLAGLACING 0x9C +#define MATROSKA_ID_TRACKFLAGORIGINAL 0x55AE #define MATROSKA_ID_TRACKMINCACHE 0x6DE7 #define MATROSKA_ID_TRACKMAXCACHE 0x6DF8 #define MATROSKA_ID_TRACKDEFAULTDURATION 0x23E383 diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index fa266fcaec..f15bf8f9d2 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -251,6 +251,7 @@ typedef struct MatroskaTrack { uint64_t flag_default; uint64_t flag_forced; uint64_t flag_comment; +CountedElement flag_original; uint64_t seek_preroll; MatroskaTrackVideo video; MatroskaTrackAudio audio; @@ -410,7 +411,7 @@ typedef struct MatroskaDemuxContext { // incomplete type (6.7.2 in C90, 6.9.2 in C99). // Removing the sizes breaks MSVC. static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19], - matroska_track[28], matroska_track_encoding[6], matroska_track_encodings[2], + matroska_track[29], matroska_track_encoding[6], matroska_track_encodings[2], matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2], matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2], matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2], @@ -575,6 +576,7 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_TRACKFLAGCOMMENTARY, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_comment), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGDEFAULT, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_default), { .u = 1 } }, { MATROSKA_ID_TRACKFLAGFORCED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_forced), { .u = 0 } }, +{ MATROSKA_ID_TRACKFLAGORIGINAL, EBML_UINT, 1, 0, offsetof(MatroskaTrack, flag_original), {.u = 0 } }, { MATROSKA_ID_TRACKVIDEO,EBML_NEST, 0, 0, offsetof(MatroskaTrack, video),{ .n = matroska_track_video } }, { MATROSKA_ID_TRACKAUDIO,EBML_NEST, 0, 0, offsetof(MatroskaTrack, audio),{ .n = matroska_track_audio } }, { MATROSKA_ID_TRACKOPERATION,EBML_NEST, 0, 0, offsetof(MatroskaTrack, operation),{ .n = matroska_track_operation } }, @@ -2746,6 +2748,9 @@ static int matroska_parse_tracks(AVFormatContext *s) st->disposition |= AV_DISPOSITION_FORCED; if (track->flag_comment) st->disposition |= AV_DISPOSITION_COMMENT; +if (track->flag_original.count > 0) +st->disposition |= track->flag_original.el.u ? AV_DISPOSITION_ORIGINAL + : AV_DISPOSITION_DUB; if (!st->codecpar->extradata) { if (extradata) { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/19] avformat/matroskadec: Don't use fake default value for ReferenceBlock
This has been done in order to find out whether this element is present at all; but this can now be done in a cleaner way by using a CountedElement for it. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index e6f4faa337..069c879404 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -330,7 +330,7 @@ typedef struct MatroskaLevel { typedef struct MatroskaBlock { uint64_t duration; -int64_t reference; +CountedElement reference; uint64_t non_simple; EbmlBin bin; uint64_t additional_id; @@ -736,7 +736,7 @@ static EbmlSyntax matroska_blockgroup[] = { { MATROSKA_ID_BLOCKADDITIONS, EBML_NEST, 0, 0, 0, { .n = matroska_blockadditions} }, { MATROSKA_ID_BLOCKDURATION, EBML_UINT, 0, 0, offsetof(MatroskaBlock, duration) }, { MATROSKA_ID_DISCARDPADDING, EBML_SINT, 0, 0, offsetof(MatroskaBlock, discard_padding) }, -{ MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 0, 0, offsetof(MatroskaBlock, reference), { .i = INT64_MIN } }, +{ MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 1, 0, offsetof(MatroskaBlock, reference) }, { MATROSKA_ID_CODECSTATE, EBML_NONE }, { 1, EBML_UINT, 0, 0, offsetof(MatroskaBlock, non_simple), { .u = 1 } }, CHILD_OF(matroska_cluster_parsing) @@ -3737,7 +3737,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) res = ebml_parse(matroska, matroska_cluster_parsing, cluster); if (res >= 0 && block->bin.size > 0) { -int is_keyframe = block->non_simple ? block->reference == INT64_MIN : -1; +int is_keyframe = block->non_simple ? block->reference.count == 0 : -1; uint8_t* additional = block->additional.size > 0 ? block->additional.data : NULL; -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/19] avformat/matroskadec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index bfc6641a5f..636ed23f0d 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1006,15 +1006,15 @@ static int ebml_read_ascii(AVIOContext *pb, int size, if (!res) return AVERROR(ENOMEM); } else { -/* EBML strings are usually not 0-terminated, so we allocate one - * byte more, read the string and NULL-terminate it ourselves. */ -if (!(res = av_malloc(size + 1))) -return AVERROR(ENOMEM); -if ((ret = avio_read(pb, (uint8_t *) res, size)) != size) { -av_free(res); -return ret < 0 ? ret : NEEDS_CHECKING; -} -(res)[size] = '\0'; +/* EBML strings are usually not 0-terminated, so we allocate one + * byte more, read the string and NULL-terminate it ourselves. */ +if (!(res = av_malloc(size + 1))) +return AVERROR(ENOMEM); +if ((ret = avio_read(pb, (uint8_t *) res, size)) != size) { +av_free(res); +return ret < 0 ? ret : NEEDS_CHECKING; +} +(res)[size] = '\0'; } av_free(*str); *str = res; -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 15/19] avformat/matroskadec: Add support for FlagTextDescriptions
This is the equivalent of the WebM "D_WEBVTT/DESCRIPTIONS" and is therefore only exported for subtitles. Signed-off-by: Andreas Rheinhardt --- libavformat/matroska.h| 1 + libavformat/matroskadec.c | 7 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index bee08d4398..6bec45d71a 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -101,6 +101,7 @@ #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA #define MATROSKA_ID_TRACKFLAGLACING 0x9C #define MATROSKA_ID_TRACKFLAGORIGINAL 0x55AE +#define MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS 0x55AD #define MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED 0x55AB #define MATROSKA_ID_TRACKFLAGVISUALIMPAIRED 0x55AC #define MATROSKA_ID_TRACKMINCACHE 0x6DE7 diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index fa0d86c3e4..5b1efc3d49 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -252,6 +252,7 @@ typedef struct MatroskaTrack { uint64_t flag_forced; uint64_t flag_comment; CountedElement flag_original; +uint64_t flag_textdescriptions; uint64_t flag_hearingimpaired; uint64_t flag_visualimpaired; uint64_t seek_preroll; @@ -413,7 +414,7 @@ typedef struct MatroskaDemuxContext { // incomplete type (6.7.2 in C90, 6.9.2 in C99). // Removing the sizes breaks MSVC. static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19], - matroska_track[31], matroska_track_encoding[6], matroska_track_encodings[2], + matroska_track[32], matroska_track_encoding[6], matroska_track_encodings[2], matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2], matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2], matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2], @@ -579,6 +580,7 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_TRACKFLAGDEFAULT, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_default), { .u = 1 } }, { MATROSKA_ID_TRACKFLAGFORCED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_forced), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGORIGINAL, EBML_UINT, 1, 0, offsetof(MatroskaTrack, flag_original), {.u = 0 } }, +{ MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_textdescriptions), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_hearingimpaired), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGVISUALIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_visualimpaired), { .u = 0 } }, { MATROSKA_ID_TRACKVIDEO,EBML_NEST, 0, 0, offsetof(MatroskaTrack, video),{ .n = matroska_track_video } }, @@ -2885,6 +2887,9 @@ static int matroska_parse_tracks(AVFormatContext *s) } } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) { st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; + +if (track->flag_textdescriptions) +st->disposition |= AV_DISPOSITION_DESCRIPTIONS; } } -- 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 17/19] fate/matroska: Add test for remuxing VP8 with alpha
This provides coverage for writing BlockGroups with BlockAdditional and ReferenceBlock elements. It also tests setting the hearing impaired disposition (it fits given that this video has no audio so one needs to be able to read lips to understand anything). Signed-off-by: Andreas Rheinhardt --- tests/fate/matroska.mak | 10 tests/ref/fate/matroska-vp8-alpha-remux | 33 + 2 files changed, 43 insertions(+) create mode 100644 tests/ref/fate/matroska-vp8-alpha-remux diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index be68082c21..4c10fe663f 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -90,6 +90,16 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MXF_DEMUXER\ += fate-matroska-mastering-display-metadata fate-matroska-mastering-display-metadata: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf matroska "-map 0 -map 0:0 -c:v:0 copy -c:v:1 ffv1 -c:a:0 copy -bsf:a:0 noise=amount=3 -filter:a:1 aresample -c:a:1 pcm_s16be -bsf:a:1 noise=dropamount=4" "-map 0 -c copy" "" "-show_entries stream_side_data_list:stream=index,codec_name" +# Tests writing BlockAdditional and BlockGroups with ReferenceBlock elements; +# it also tests setting a track as suitable for hearing impaired. +# It also tests the capability of the VP8 parser to set the keyframe flag +# (the input file lacks ReferenceBlock elements making everything a keyframe). +FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MATROSKA_DEMUXER \ +VP8_PARSER MATROSKA_MUXER \ +FRAMECRC_MUXER PIPE_PROTOCOL) \ + += fate-matroska-vp8-alpha-remux +fate-matroska-vp8-alpha-remux: CMD = transcode matroska $(TARGET_SAMPLES)/vp8_alpha/vp8_video_with_alpha.webm matroska "-c copy -disposition +hearing_impaired -cluster_size_limit 10" "-c copy -t 0.2" "" "-show_entries stream_disposition:stream_side_data_list" + FATE_MATROSKA_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER) += fate-matroska-spherical-mono fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream_side_data_list -select_streams v -v 0 $(TARGET_SAMPLES)/mkv/spherical.mkv diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux new file mode 100644 index 00..0b6c779323 --- /dev/null +++ b/tests/ref/fate/matroska-vp8-alpha-remux @@ -0,0 +1,33 @@ +d06be833da8e8d9d00bf334e0dfe8a58 *tests/data/fate/matroska-vp8-alpha-remux.matroska +237192 tests/data/fate/matroska-vp8-alpha-remux.matroska +#tb 0: 1/1000 +#media_type 0: video +#codec_id 0: vp8 +#dimensions 0: 320x213 +#sar 0: 1/1 +0, 0, 0, 33, 2108, 0x59b92a34, S=2, 1900, 0x8fb3adc5, 12, 0x +0, 32, 32, 33, 142, 0x2f2a3fed, F=0x0, S=1, 160, 0xa13346af +0, 65, 65, 33, 157, 0x17804767, F=0x0, S=1, 209, 0x64115f15 +0, 99, 99, 33, 206, 0x537262ca, F=0x0, S=1, 317, 0x44a09dd0 +0,132,132, 33, 259, 0x73ff74b6, F=0x0, S=1, 384, 0x2ee2c588 +0,165,165, 33, 320, 0x0fcf8ce4, F=0x0, S=1, 415, 0xff68c953 +0,199,199, 33, 377, 0x8fffb5f5, F=0x0, S=1, 475, 0x4166f3eb +[STREAM] +DISPOSITION:default=1 +DISPOSITION:dub=0 +DISPOSITION:original=0 +DISPOSITION:comment=0 +DISPOSITION:lyrics=0 +DISPOSITION:karaoke=0 +DISPOSITION:forced=0 +DISPOSITION:hearing_impaired=1 +DISPOSITION:visual_impaired=0 +DISPOSITION:clean_effects=0 +DISPOSITION:attached_pic=0 +DISPOSITION:timed_thumbnails=0 +[SIDE_DATA] +side_data_type=Stereo 3D +type=2D +inverted=0 +[/SIDE_DATA] +[/STREAM] -- 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 18/19] fate/matroska: Test remuxing tracks for hearing/visually impaired
The tests also test the other dispositions: commentary, descriptions as well as dub and original language. Furthermore they test e.g. muxing alac in Matroska. Signed-off-by: Andreas Rheinhardt --- tests/fate/matroska.mak | 23 + tests/ref/fate/matroska-mpegts-remux | 52 +++ tests/ref/fate/matroska-wtv-remux| 134 +++ 3 files changed, 209 insertions(+) create mode 100644 tests/ref/fate/matroska-mpegts-remux create mode 100644 tests/ref/fate/matroska-wtv-remux diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index 4c10fe663f..b907da40f3 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -100,6 +100,29 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MATROSKA_DEMUXER \ += fate-matroska-vp8-alpha-remux fate-matroska-vp8-alpha-remux: CMD = transcode matroska $(TARGET_SAMPLES)/vp8_alpha/vp8_video_with_alpha.webm matroska "-c copy -disposition +hearing_impaired -cluster_size_limit 10" "-c copy -t 0.2" "" "-show_entries stream_disposition:stream_side_data_list" +# The second input audio track is for the hearing impaired. It is muxed twice, +# once using streamcopy and once encoded with alac to test that dispositions +# are preserved during encoding; the streamcopied track is also marked as +# commentary. The other audio stream is also muxed twice, once streamcopied, +# once as pcm_s24be; one of them is marked as dub and one as original language. +# The subtitle stream is furthermore marked as containing descriptions. +FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL WTV_DEMUXER \ +MPEGAUDIO_PARSER DVBSUB_PARSER \ +MP2_DECODER ARESAMPLE_FILTER\ +ALAC_ENCODER PCM_S24BE_ENCODER \ +MATROSKA_MUXER MATROSKA_DEMUXER \ +FRAMECRC_MUXER PIPE_PROTOCOL) \ + += fate-matroska-wtv-remux +fate-matroska-wtv-remux: CMD = transcode wtv $(TARGET_SAMPLES)/wtv/law-and-order-partial.wtv matroska "-map 0 -vn -map 0:a:1 -c:s copy -disposition:s +descriptions -c:a:0 copy -disposition:a:0 +original -c:a:1 copy -disposition:a:1 +comment -c:a:2 alac -map 0:a:0 -filter:a:3 aresample -c:a:3 pcm_s24be -disposition:a:3 +dub" "-map 0 -c copy -t 0.2" "" "-show_entries stream_disposition:stream=index,codec_name" + +# The audio stream to be remuxed here has AV_DISPOSITION_VISUAL_IMPAIRED. +FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MPEGTS_DEMUXER\ +AC3_DECODER MATROSKA_MUXER \ +MATROSKA_DEMUXER FRAMECRC_MUXER \ +PIPE_PROTOCOL) \ + += fate-matroska-mpegts-remux +fate-matroska-mpegts-remux: CMD = transcode mpegts $(TARGET_SAMPLES)/mpegts/pmtchange.ts matroska "-map 0:2 -map 0:2 -c copy -disposition:a:1 -visual_impaired+hearing_impaired" "-map 0 -c copy" "" "-show_entries stream_disposition:stream=index" + FATE_MATROSKA_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER) += fate-matroska-spherical-mono fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream_side_data_list -select_streams v -v 0 $(TARGET_SAMPLES)/mkv/spherical.mkv diff --git a/tests/ref/fate/matroska-mpegts-remux b/tests/ref/fate/matroska-mpegts-remux new file mode 100644 index 00..3c0b41cca9 --- /dev/null +++ b/tests/ref/fate/matroska-mpegts-remux @@ -0,0 +1,52 @@ +4e6253c1f5f96ff64ae855dea426547d *tests/data/fate/matroska-mpegts-remux.matroska +6509 tests/data/fate/matroska-mpegts-remux.matroska +#tb 0: 1/1000 +#media_type 0: audio +#codec_id 0: ac3 +#sample_rate 0: 48000 +#channel_layout 0: 3 +#channel_layout_name 0: stereo +#tb 1: 1/1000 +#media_type 1: audio +#codec_id 1: ac3 +#sample_rate 1: 48000 +#channel_layout 1: 3 +#channel_layout_name 1: stereo +0, 0, 0, 32, 768, 0xa63778d4 +1, 0, 0, 32, 768, 0xa63778d4 +0, 32, 32, 32, 768, 0x7d577f3f +1, 32, 32, 32, 768, 0x7d577f3f +0, 64, 64, 32, 768, 0xd86b7c8f +1, 64, 64, 32, 768, 0xd86b7c8f +0, 96, 96, 32, 626, 0x09f4382f +1, 96, 96, 32, 626, 0x09f4382f +[STREAM] +index=0 +DISPOSITION:default=1 +DISPOSITION:dub=0 +DISPOSITION:original=0 +DISPOSITION:comment=0 +DISPOSITION:lyrics=0 +DISPOSITION:karaoke=0 +DISPOSITION:forced=0 +DISPOSITION:hearing_impaired=0 +DISPOSITION:visual_impaired=1 +DISPOSITION:clean_effects=0 +DISPOSITION:attached_pic=0 +DISPOSITION:timed_thumbnails=0 +[/STREAM] +[STREAM] +index=1 +DISPOSITION:default=0 +DISPOSITION:dub=0 +DISPOSITION:orig
[FFmpeg-devel] [PATCH 14/19] avformat/matroskaenc: Add support for FlagHearing/VisualImpaired
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 0dd093ae8b..86ffb51051 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1198,6 +1198,10 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, != (AV_DISPOSITION_ORIGINAL | AV_DISPOSITION_DUB)) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGORIGINAL, !!(st->disposition & AV_DISPOSITION_ORIGINAL)); +if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) +put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED, 1); +if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) +put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGVISUALIMPAIRED, 1); // look for a codec ID string specific to mkv to use, // if none are found, use AVI codes -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 13/19] avformat/matroskadec: Add support for FlagHearing/VisualImpaired
Given that our disposition flags provide no way to distinguish the cases of "track is unsuitable for hearing impaired users" and "it is unknown whether the track is suitable for hearing impaired users" we do not need to use a CountedElement for these flags. Signed-off-by: Andreas Rheinhardt --- libavformat/matroska.h| 2 ++ libavformat/matroskadec.c | 10 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 8ab87eff20..bee08d4398 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -101,6 +101,8 @@ #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA #define MATROSKA_ID_TRACKFLAGLACING 0x9C #define MATROSKA_ID_TRACKFLAGORIGINAL 0x55AE +#define MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED 0x55AB +#define MATROSKA_ID_TRACKFLAGVISUALIMPAIRED 0x55AC #define MATROSKA_ID_TRACKMINCACHE 0x6DE7 #define MATROSKA_ID_TRACKMAXCACHE 0x6DF8 #define MATROSKA_ID_TRACKDEFAULTDURATION 0x23E383 diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index f15bf8f9d2..fa0d86c3e4 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -252,6 +252,8 @@ typedef struct MatroskaTrack { uint64_t flag_forced; uint64_t flag_comment; CountedElement flag_original; +uint64_t flag_hearingimpaired; +uint64_t flag_visualimpaired; uint64_t seek_preroll; MatroskaTrackVideo video; MatroskaTrackAudio audio; @@ -411,7 +413,7 @@ typedef struct MatroskaDemuxContext { // incomplete type (6.7.2 in C90, 6.9.2 in C99). // Removing the sizes breaks MSVC. static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19], - matroska_track[29], matroska_track_encoding[6], matroska_track_encodings[2], + matroska_track[31], matroska_track_encoding[6], matroska_track_encodings[2], matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2], matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2], matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2], @@ -577,6 +579,8 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_TRACKFLAGDEFAULT, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_default), { .u = 1 } }, { MATROSKA_ID_TRACKFLAGFORCED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_forced), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGORIGINAL, EBML_UINT, 1, 0, offsetof(MatroskaTrack, flag_original), {.u = 0 } }, +{ MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_hearingimpaired), { .u = 0 } }, +{ MATROSKA_ID_TRACKFLAGVISUALIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_visualimpaired), { .u = 0 } }, { MATROSKA_ID_TRACKVIDEO,EBML_NEST, 0, 0, offsetof(MatroskaTrack, video),{ .n = matroska_track_video } }, { MATROSKA_ID_TRACKAUDIO,EBML_NEST, 0, 0, offsetof(MatroskaTrack, audio),{ .n = matroska_track_audio } }, { MATROSKA_ID_TRACKOPERATION,EBML_NEST, 0, 0, offsetof(MatroskaTrack, operation),{ .n = matroska_track_operation } }, @@ -2751,6 +2755,10 @@ static int matroska_parse_tracks(AVFormatContext *s) if (track->flag_original.count > 0) st->disposition |= track->flag_original.el.u ? AV_DISPOSITION_ORIGINAL : AV_DISPOSITION_DUB; +if (track->flag_hearingimpaired) +st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED; +if (track->flag_visualimpaired) +st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED; if (!st->codecpar->extradata) { if (extradata) { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/19] avformat/matroskaenc: Don't write empty language
According to the new EBML specifications, a string element of length zero would be read as the default value by a compliant parser. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 233c472b8f..786fa41cba 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1147,7 +1147,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value); tag = av_dict_get(st->metadata, "language", NULL, 0); put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, -tag && tag->value ? tag->value : "und"); +tag && tag->value && tag->value[0] ? tag->value : "und"); // The default value for TRACKFLAGDEFAULT is 1, so add element // if we need to clear it. -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 09/19] avformat/matroska, matroskadec: Support FlagCommentary
Hint: Matroska actually provides a way to distinguish the cases of "track is no commentary track" and "it is unknown whether the track is a commentary track", but our disposition flags do not. Therefore we need not use a CountedElement. Signed-off-by: Andreas Rheinhardt --- libavformat/matroska.h| 1 + libavformat/matroskadec.c | 6 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 6f198f06e6..191c4f6149 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -95,6 +95,7 @@ #define MATROSKA_ID_SEEKPREROLL 0x56BB #define MATROSKA_ID_TRACKNAME 0x536E #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C +#define MATROSKA_ID_TRACKFLAGCOMMENTARY 0x55AF #define MATROSKA_ID_TRACKFLAGENABLED 0xB9 #define MATROSKA_ID_TRACKFLAGDEFAULT 0x88 #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b9c6047f56..fa266fcaec 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -250,6 +250,7 @@ typedef struct MatroskaTrack { uint64_t default_duration; uint64_t flag_default; uint64_t flag_forced; +uint64_t flag_comment; uint64_t seek_preroll; MatroskaTrackVideo video; MatroskaTrackAudio audio; @@ -409,7 +410,7 @@ typedef struct MatroskaDemuxContext { // incomplete type (6.7.2 in C90, 6.9.2 in C99). // Removing the sizes breaks MSVC. static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19], - matroska_track[27], matroska_track_encoding[6], matroska_track_encodings[2], + matroska_track[28], matroska_track_encoding[6], matroska_track_encodings[2], matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2], matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2], matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2], @@ -571,6 +572,7 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_TRACKLANGUAGE, EBML_STR, 0, 0, offsetof(MatroskaTrack, language), { .s = "eng" } }, { MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, 0, offsetof(MatroskaTrack, default_duration) }, { MATROSKA_ID_TRACKTIMECODESCALE,EBML_FLOAT, 0, 0, offsetof(MatroskaTrack, time_scale), { .f = 1.0 } }, +{ MATROSKA_ID_TRACKFLAGCOMMENTARY, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_comment), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGDEFAULT, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_default), { .u = 1 } }, { MATROSKA_ID_TRACKFLAGFORCED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_forced), { .u = 0 } }, { MATROSKA_ID_TRACKVIDEO,EBML_NEST, 0, 0, offsetof(MatroskaTrack, video),{ .n = matroska_track_video } }, @@ -2742,6 +2744,8 @@ static int matroska_parse_tracks(AVFormatContext *s) st->disposition |= AV_DISPOSITION_DEFAULT; if (track->flag_forced) st->disposition |= AV_DISPOSITION_FORCED; +if (track->flag_comment) +st->disposition |= AV_DISPOSITION_COMMENT; if (!st->codecpar->extradata) { if (extradata) { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 12/19] avformat/matroskaenc: Add support for FlagOriginal
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 746c0b347a..0dd093ae8b 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1193,6 +1193,12 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, } else { if (st->disposition & AV_DISPOSITION_COMMENT) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGCOMMENTARY, 1); +if (st->disposition & (AV_DISPOSITION_ORIGINAL | AV_DISPOSITION_DUB) && +(st->disposition & (AV_DISPOSITION_ORIGINAL | AV_DISPOSITION_DUB)) +!= (AV_DISPOSITION_ORIGINAL | AV_DISPOSITION_DUB)) +put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGORIGINAL, + !!(st->disposition & AV_DISPOSITION_ORIGINAL)); + // look for a codec ID string specific to mkv to use, // if none are found, use AVI codes if (par->codec_id != AV_CODEC_ID_RAWVIDEO || par->codec_tag) { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 08/19] avformat/matroskadec: Beautify setting default values
Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 636ed23f0d..b9c6047f56 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1114,28 +1114,29 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, int res; if (data) { -for (int i = 0; syntax[i].id; i++) +for (int i = 0; syntax[i].id; i++) { +void *dst = (char *)data + syntax[i].data_offset; switch (syntax[i].type) { case EBML_UINT: -*(uint64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.u; +*(uint64_t *)dst = syntax[i].def.u; break; case EBML_SINT: -*(int64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.i; +*(int64_t *) dst = syntax[i].def.i; break; case EBML_FLOAT: -*(double *) ((char *) data + syntax[i].data_offset) = syntax[i].def.f; +*(double *) dst = syntax[i].def.f; break; case EBML_STR: case EBML_UTF8: // the default may be NULL if (syntax[i].def.s) { -uint8_t **dst = (uint8_t **) ((uint8_t *) data + syntax[i].data_offset); -*dst = av_strdup(syntax[i].def.s); -if (!*dst) +*(char**)dst = av_strdup(syntax[i].def.s); +if (!*(char**)dst) return AVERROR(ENOMEM); } break; } +} if (!matroska->levels[matroska->num_levels - 1].length) { matroska->num_levels--; -- 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 19/19] fate/matroska: Add fate-matroska target
Signed-off-by: Andreas Rheinhardt --- tests/fate/matroska.mak | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index b907da40f3..c7da2465b5 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -129,3 +129,5 @@ fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entrie FATE_SAMPLES_AVCONV += $(FATE_MATROSKA-yes) FATE_SAMPLES_FFPROBE += $(FATE_MATROSKA_FFPROBE-yes) FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MATROSKA_FFMPEG_FFPROBE-yes) + +fate-matroska: $(FATE_MATROSKA-yes) $(FATE_MATROSKA_FFPROBE-yes) $(FATE_MATROSKA_FFMPEG_FFPROBE-yes) -- 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 16/19] avformat/matroskaenc: Add support for FlagTextDescriptions
This is the Matroska equivalent of D_WEBVTT_DESCRIPTIONS and is therefore only enabled for subtitles. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 86ffb51051..4242d7daef 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1364,6 +1364,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", par->codec_id); return AVERROR(ENOSYS); } +if (mkv->mode != MODE_WEBM && st->disposition & AV_DISPOSITION_DESCRIPTIONS) +put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS, 1); if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) native_id = MATROSKA_TRACK_TYPE_SUBTITLE; -- 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 06/19] avformat/matroskadec: Make reading zero-length elements spec-compliant
For a very long time, the payload of integer and float elements had to have a length > 0. Our parser treated such invalid elements as having a value zero. But now it has been defined what an EBML element with length zero means: It is a shorthand for the default value. This has also been defined for strings (both ASCII and UTF-8). This commit modifies our parser to support this. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 50 ++- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 069c879404..bfc6641a5f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -929,12 +929,17 @@ static int ebml_read_length(MatroskaDemuxContext *matroska, AVIOContext *pb, /* * Read the next element as an unsigned int. - * Returns NEEDS_CHECKING. + * Returns NEEDS_CHECKING unless size == 0. */ -static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num) +static int ebml_read_uint(AVIOContext *pb, int size, + uint64_t default_value, uint64_t *num) { int n = 0; +if (size == 0) { +*num = default_value; +return 0; +} /* big-endian ordering; build up number */ *num = 0; while (n++ < size) @@ -945,14 +950,16 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num) /* * Read the next element as a signed int. - * Returns NEEDS_CHECKING. + * Returns NEEDS_CHECKING unless size == 0. */ -static int ebml_read_sint(AVIOContext *pb, int size, int64_t *num) +static int ebml_read_sint(AVIOContext *pb, int size, + int64_t default_value, int64_t *num) { int n = 1; if (size == 0) { -*num = 0; +*num = default_value; +return 0; } else { *num = sign_extend(avio_r8(pb), 8); @@ -966,17 +973,19 @@ static int ebml_read_sint(AVIOContext *pb, int size, int64_t *num) /* * Read the next element as a float. - * Returns NEEDS_CHECKING or < 0 on obvious failure. + * Returns 0 if size == 0, NEEDS_CHECKING or < 0 on obvious failure. */ -static int ebml_read_float(AVIOContext *pb, int size, double *num) +static int ebml_read_float(AVIOContext *pb, int size, + double default_value, double *num) { -if (size == 0) -*num = 0; -else if (size == 4) +if (size == 0) { +*num = default_value; +return 0; +} else if (size == 4) { *num = av_int2float(avio_rb32(pb)); -else if (size == 8) +} else if (size == 8) { *num = av_int2double(avio_rb64(pb)); -else +} else return AVERROR_INVALIDDATA; return NEEDS_CHECKING; @@ -986,11 +995,17 @@ static int ebml_read_float(AVIOContext *pb, int size, double *num) * Read the next element as an ASCII string. * 0 is success, < 0 or NEEDS_CHECKING is failure. */ -static int ebml_read_ascii(AVIOContext *pb, int size, char **str) +static int ebml_read_ascii(AVIOContext *pb, int size, + const char *default_value, char **str) { char *res; int ret; +if (size == 0 && default_value) { +res = av_strdup(default_value); +if (!res) +return AVERROR(ENOMEM); +} else { /* EBML strings are usually not 0-terminated, so we allocate one * byte more, read the string and NULL-terminate it ourselves. */ if (!(res = av_malloc(size + 1))) @@ -1000,6 +1015,7 @@ static int ebml_read_ascii(AVIOContext *pb, int size, char **str) return ret < 0 ? ret : NEEDS_CHECKING; } (res)[size] = '\0'; +} av_free(*str); *str = res; @@ -1396,17 +1412,17 @@ static int ebml_parse(MatroskaDemuxContext *matroska, switch (syntax->type) { case EBML_UINT: -res = ebml_read_uint(pb, length, data); +res = ebml_read_uint(pb, length, syntax->def.u, data); break; case EBML_SINT: -res = ebml_read_sint(pb, length, data); +res = ebml_read_sint(pb, length, syntax->def.i, data); break; case EBML_FLOAT: -res = ebml_read_float(pb, length, data); +res = ebml_read_float(pb, length, syntax->def.f, data); break; case EBML_STR: case EBML_UTF8: -res = ebml_read_ascii(pb, length, data); +res = ebml_read_ascii(pb, length, syntax->def.s, data); break; case EBML_BIN: res = ebml_read_binary(pb, length, pos_alt, data); -- 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".
Re: [FFmpeg-devel] [PATCH] arm/aarch64: Use mach_absolute_time as timer on apple platforms
On Fri, 12 Feb 2021, Martin Storsjö wrote: This is much less precise than the cycle counter register, but the cycle counter register is not available on apple platforms (and on linux, it requires a kernel module for allowing user mode access). --- libavutil/aarch64/timer.h | 8 +++- libavutil/arm/timer.h | 8 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libavutil/aarch64/timer.h b/libavutil/aarch64/timer.h index b570039416..8b28fd354c 100644 --- a/libavutil/aarch64/timer.h +++ b/libavutil/aarch64/timer.h @@ -24,7 +24,13 @@ #include #include "config.h" -#if HAVE_INLINE_ASM +#if defined(__APPLE__) + +#include + +#define AV_READ_TIME mach_absolute_time + +#elif HAVE_INLINE_ASM #define AV_READ_TIME read_time diff --git a/libavutil/arm/timer.h b/libavutil/arm/timer.h index 5e8bc8edd0..caf23e2a5a 100644 --- a/libavutil/arm/timer.h +++ b/libavutil/arm/timer.h @@ -24,7 +24,13 @@ #include #include "config.h" -#if HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__) +#if defined(__APPLE__) + +#include + +#define AV_READ_TIME mach_absolute_time + +#elif HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__) #define AV_READ_TIME read_time -- 2.25.1 I'll push this soon if there's no comments. // Martin ___ 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 4/6] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"
On Wed, Feb 17, 2021 at 9:14 AM Anton Khirnov wrote: > Quoting Paul B Mahol (2021-02-16 21:57:47) > > Do you have actual proof for such claims? > > The burden of proof is on you here - you are supposed to prove that your > commit fixes something. And when I asked you about details, you couldn't > even tell me what the bug was, much less why would switching the order > of allocations be the correct fix for it. > It is not about order of allocations. > > > > > There is no point in reverting commit if that commit fixed some behavior. > > It didn't fix anything though. Before your commit, frame 69 of the > sample in #9017 is almost black with 1 thread and looks okay with 2 > threads. After your commit, it is almost black in both cases. So your > commit made it consistently wrong. This shows up in my tests and is also > You are mistaken. It fixed race. Prove it does not. Another patch is supposed to fix output for both single and multi threads. > supported by the last comment in https://trac.ffmpeg.org/ticket/9017 > Feel free to test it yourself. > > Next not reviewed patch fixed it completely. Thanks for actually confirming it makes consistent result with different threads and as such commit should not be reverted. If you have no proof that your changes too apng code improves anything besides line counts than I nack whole patch set. I have not tested your set at all. But plan to if you provide file you used to actually test this and that file is different from already provided file on trac. -- > 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 5/6] pngdec: fix and simplify apng reference handling
On Tue, Feb 16, 2021 at 9:26 PM Anton Khirnov wrote: > Current code is very confused and confusing. It uses two different > reference frames - "previous" and "last" - when only one is really > necessary. It also confuses the two, leading to incorrect output with > APNG_DISPOSE_OP_PREVIOUS mode. > > Fixes #9017. > --- > libavcodec/pngdec.c | 93 - > 1 file changed, 42 insertions(+), 51 deletions(-) > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c > index d02c45f1a7..cece08ebca 100644 > --- a/libavcodec/pngdec.c > +++ b/libavcodec/pngdec.c > @@ -54,7 +54,6 @@ typedef struct PNGDecContext { > AVCodecContext *avctx; > > GetByteContext gb; > -ThreadFrame previous_picture; > ThreadFrame last_picture; > ThreadFrame picture; > > @@ -711,13 +710,10 @@ static int decode_idat_chunk(AVCodecContext *avctx, > PNGDecContext *s, > s->bpp += byte_depth; > } > > +ff_thread_release_buffer(avctx, &s->picture); > if ((ret = ff_thread_get_buffer(avctx, &s->picture, > AV_GET_BUFFER_FLAG_REF)) < 0) > return ret; > -if (avctx->codec_id == AV_CODEC_ID_APNG && s->last_dispose_op != > APNG_DISPOSE_OP_PREVIOUS) { > -ff_thread_release_buffer(avctx, &s->previous_picture); > -if ((ret = ff_thread_get_buffer(avctx, &s->previous_picture, > AV_GET_BUFFER_FLAG_REF)) < 0) > -return ret; > -} > + > p->pict_type= AV_PICTURE_TYPE_I; > p->key_frame= 1; > p->interlaced_frame = !!s->interlace_type; > @@ -1020,7 +1016,7 @@ static int decode_fctl_chunk(AVCodecContext *avctx, > PNGDecContext *s, > return AVERROR_INVALIDDATA; > } > > -if ((sequence_number == 0 || !s->previous_picture.f->data[0]) && > +if ((sequence_number == 0 || !s->last_picture.f->data[0]) && > dispose_op == APNG_DISPOSE_OP_PREVIOUS) { > // No previous frame to revert to for the first frame > // Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND > @@ -1088,23 +1084,23 @@ static int handle_p_frame_apng(AVCodecContext > *avctx, PNGDecContext *s, > if (!buffer) > return AVERROR(ENOMEM); > > +ff_thread_await_progress(&s->last_picture, INT_MAX, 0); > > -// Do the disposal operation specified by the last frame on the frame > -if (s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) { > -ff_thread_await_progress(&s->last_picture, INT_MAX, 0); > -memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * > s->height); > - > -if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) > -for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; > ++y) > -memset(buffer + s->image_linesize * y + s->bpp * > s->last_x_offset, 0, s->bpp * s->last_w); > +// need to reset a rectangle to background: > +// create a new writable copy > +if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) { > +int ret = av_frame_make_writable(s->last_picture.f); > +if (ret < 0) > +return ret; > > -memcpy(s->previous_picture.f->data[0], buffer, s->image_linesize > * s->height); > -ff_thread_report_progress(&s->previous_picture, INT_MAX, 0); > -} else { > -ff_thread_await_progress(&s->previous_picture, INT_MAX, 0); > -memcpy(buffer, s->previous_picture.f->data[0], s->image_linesize > * s->height); > +for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) > { > +memset(s->last_picture.f->data[0] + s->image_linesize * y + > + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); > +} > } > > +memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * > s->height); > + > // Perform blending > if (s->blend_op == APNG_BLEND_OP_SOURCE) { > for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { > @@ -1448,22 +1444,17 @@ exit_loop: > if (CONFIG_PNG_DECODER && avctx->codec_id != AV_CODEC_ID_APNG) > handle_p_frame_png(s, p); > else if (CONFIG_APNG_DECODER && > - s->previous_picture.f->width == p->width && > - s->previous_picture.f->height== p->height && > - s->previous_picture.f->format== p->format && > No explanation provided why those line are removed. > avctx->codec_id == AV_CODEC_ID_APNG && > (ret = handle_p_frame_apng(avctx, s, p)) < 0) > goto fail; > } > } > ff_thread_report_progress(&s->picture, INT_MAX, 0); > -ff_thread_report_progress(&s->previous_picture, INT_MAX, 0); > > return 0; > > fail: > ff_thread_report_progress(&s->picture, INT_MAX, 0); > -ff_thread_report_progress(&s->previous_picture, INT_MAX, 0); > return ret; > } > > @@ -1475,14 +1466,10 @@ static int decode_frame_png(AVCodecContext
Re: [FFmpeg-devel] [PATCH v3] avcodec/libvpxenc: fix potential memory leak.
Wonkap Jang (12021-02-16): > While parsing ref_frame_config, AVdictionary needs to be manually > deallocated. > --- > libavcodec/libvpxenc.c | 19 --- > 1 file changed, 12 insertions(+), 7 deletions(-) NAK. This code is all wrong, it looks like Java or Python, it should not be using a dictionary in the first place, even less a dictionary stored in the context. Just iterate over the key=value pairs of the string without allocating all of them longer than necessary. 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 4/6] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"
On Wed, 17 Feb 2021, at 11:45, Paul B Mahol wrote: > > It didn't fix anything though. Before your commit, frame 69 of the > > sample in #9017 is almost black with 1 thread and looks okay with 2 > > threads. After your commit, it is almost black in both cases. So your > > commit made it consistently wrong. This shows up in my tests and is also > > You are mistaken. It fixed race. Prove it does not. > Another patch is supposed to fix output for both single and multi threads. Which patch fixes everything? -- Jean-Baptiste Kempf - President +33 672 704 734 ___ 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/1] avcodec/libopusdec: Enable FEC/PLC
> Could you elaborate? > I would have expected that the normal use case is not have a > lossy input and that the new feature is always useful if data > was lost. The use-case for FEC is typically RTP stream where audio is compressed with opus. In that case, depending on the network conditions, packets can be lost. From the decoder side, this can be observed as a packet with a pts that is incremented more than we would expect. With this patch, if no discontinuity is detected, the packet is decoded as usual. If a discontinuity is detected, its duration is checked to deduct how many samples should be reconstructed. One limitation of opus FEC is that packets can be reconstructed with a granularity of 2.5ms (120 samples), so libopus can not jsut reconstruct an arbitrary number of samples. This patch manages this by "rounding" the number of lost samples to the closest number of samples that libopsu can reconstruct. > Or is there no way to distinguish between a stream with > unusual timestamps and a stream with packet loss? From my understanding, the only information at the decoder side are the metadata associated with the packet to decode, notably the pts, dts and packet duration. It does not have information about how the packet has been received (RTP, SDP, other...). Packet loss can typically be detected at higher layers (RTCP packets for RTP) but not at the decoder layer. From observation it seemed that a pts different from the last pts + packet duration would indicate that some samples were lost. The decoder than tries to restore as much sample as it can. Note that packet duration seem to change units depending on how the file is encapsulated: the same file had a packet->duration of 20 (ms) in a .mkv container but 960 (samples) in a .opus container. Since the decoder is not aware of which container is used, it has to "guess" which unit is used. As FEC is ony used with SILK frames, which have a 10ms (480 samples) minimal duration, and an opus packet has a max duration of 120ms, a threshold can find how the pts is expressed. An alternative could be to simply provide a new function to decode FEC data and let the higher layers manage if FEC should be decoded, but this implies more modification to the stack to make FEC work, while here only an AVOption has to be set. ___ 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/1] avcodec/libopusdec: Enable FEC/PLC
>> Am Di., 16. Feb. 2021 um 15:02 Uhr schrieb Philip-Dylan Gleonec >> : >> >>> >>> Adds FEC/PLC support to libopus. The lost packets are detected as a >>> discontinuity in the audio stream. When a discontinuity is used, this >>> patch tries to decode the FEC data. If FEC data is present in the >>> packet, it is decoded, otherwise audio is re-created through PLC. >>> >>> This patch is based on Steinar H. Gunderson contribution, and corrects >>> the pts computation: all pts are expressed in samples instead of time. >>> This patch also adds an option "decode_fec" which enables or disables >>> FEC decoding. This option is disabled by default to keep consistent >>> behaviour with former versions. >>> >> >> Could you elaborate? >> I would have expected that the normal use case is not have a >> lossy input and that the new feature is always useful if data >> was lost. >> >> Or is there no way to distinguish between a stream with >> unusual timestamps and a stream with packet loss? >> > >Streams can switch between being FEC encoded and not on >a per-frame basis. Opus streams can have odd timestamps >since the frame size is somewhat variable. So no way to >check purely on timestamps. Is there a possibility of the packet duration varying ? I'm not sure this patch can manage this case, though it could by comparing the pts to the last pts + the new packet duration. >I'd like to have the original patch author review this, could >someone CC him? I've added him to the CC list. ___ 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/1] avcodec/libopusdec: Enable FEC/PLC
> I've added him to the CC list Now done. ___ 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/1] avcodec/libopusdec: Enable FEC/PLC
Philip-Dylan Gleonec: >> Could you elaborate? >> I would have expected that the normal use case is not have a >> lossy input and that the new feature is always useful if data >> was lost. > > The use-case for FEC is typically RTP stream where audio is compressed > with opus. In that case, depending on the network conditions, packets > can be lost. From the decoder side, this can be observed as a packet > with a pts that is incremented more than we would expect. > > With this patch, if no discontinuity is detected, the packet is decoded > as usual. If a discontinuity is detected, its duration is checked to > deduct how many samples should be reconstructed. One limitation of opus > FEC is that packets can be reconstructed with a granularity of 2.5ms > (120 samples), so libopus can not jsut reconstruct an arbitrary number > of samples. This patch manages this by "rounding" the number of lost > samples to the closest number of samples that libopsu can reconstruct. > >> Or is there no way to distinguish between a stream with >> unusual timestamps and a stream with packet loss? > > From my understanding, the only information at the decoder side are the > metadata associated with the packet to decode, notably the pts, dts and > packet duration. It does not have information about how the packet has > been received (RTP, SDP, other...). Packet loss can typically be > detected at higher layers (RTCP packets for RTP) but not at the decoder > layer. > > From observation it seemed that a pts different from the last pts + > packet duration would indicate that some samples were lost. The decoder > than tries to restore as much sample as it can. > > Note that packet duration seem to change units depending on how the file > is encapsulated: the same file had a packet->duration of 20 (ms) in a > .mkv container but 960 (samples) in a .opus container. Since the decoder > is not aware of which container is used, it has to "guess" which unit is > used. As FEC is ony used with SILK frames, which have a 10ms (480 > samples) minimal duration, and an opus packet has a max duration of > 120ms, a threshold can find how the pts is expressed. There is AVCodecContext.pkt_timebase. > > An alternative could be to simply provide a new function to decode FEC > data and let the higher layers manage if FEC should be decoded, but this > implies more modification to the stack to make FEC work, while here only > an AVOption has to be set. ___ 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 4/6] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"
Quoting Paul B Mahol (2021-02-17 11:45:02) > On Wed, Feb 17, 2021 at 9:14 AM Anton Khirnov wrote: > > > Quoting Paul B Mahol (2021-02-16 21:57:47) > > > Do you have actual proof for such claims? > > > > The burden of proof is on you here - you are supposed to prove that your > > commit fixes something. And when I asked you about details, you couldn't > > even tell me what the bug was, much less why would switching the order > > of allocations be the correct fix for it. > > > > It is not about order of allocations. What is it about then? > > > > > > > > > > There is no point in reverting commit if that commit fixed some behavior. > > > > It didn't fix anything though. Before your commit, frame 69 of the > > sample in #9017 is almost black with 1 thread and looks okay with 2 > > threads. After your commit, it is almost black in both cases. So your > > commit made it consistently wrong. This shows up in my tests and is also > > > > > You are mistaken. It fixed race. Prove it does not. You have it backwards. You are making a claim - that your patch fixes a race. It is your responsibility to prove that your patch is correct. So far you did not even explain what this supposed race is. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavfi/drawtext: ignore final LF of textfile.
Nicolas George (12020-11-30): > Good idea, thanks. Pushed. 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 5/6] pngdec: fix and simplify apng reference handling
Quoting Paul B Mahol (2021-02-17 11:52:31) > On Tue, Feb 16, 2021 at 9:26 PM Anton Khirnov wrote: > > @@ -1088,23 +1084,23 @@ static int handle_p_frame_apng(AVCodecContext > > *avctx, PNGDecContext *s, > > if (!buffer) > > return AVERROR(ENOMEM); > > > > +ff_thread_await_progress(&s->last_picture, INT_MAX, 0); > > > > -// Do the disposal operation specified by the last frame on the frame > > -if (s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) { > > -ff_thread_await_progress(&s->last_picture, INT_MAX, 0); > > -memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * > > s->height); > > - > > -if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) > > -for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; > > ++y) > > -memset(buffer + s->image_linesize * y + s->bpp * > > s->last_x_offset, 0, s->bpp * s->last_w); > > +// need to reset a rectangle to background: > > +// create a new writable copy > > +if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) { > > +int ret = av_frame_make_writable(s->last_picture.f); > > +if (ret < 0) > > +return ret; > > > > -memcpy(s->previous_picture.f->data[0], buffer, s->image_linesize > > * s->height); > > -ff_thread_report_progress(&s->previous_picture, INT_MAX, 0); > > -} else { > > -ff_thread_await_progress(&s->previous_picture, INT_MAX, 0); > > -memcpy(buffer, s->previous_picture.f->data[0], s->image_linesize > > * s->height); > > +for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) > > { > > +memset(s->last_picture.f->data[0] + s->image_linesize * y + > > + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); > > +} > > } > > > > +memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * > > s->height); > > + > > // Perform blending > > if (s->blend_op == APNG_BLEND_OP_SOURCE) { > > for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { > > @@ -1448,22 +1444,17 @@ exit_loop: > > if (CONFIG_PNG_DECODER && avctx->codec_id != AV_CODEC_ID_APNG) > > handle_p_frame_png(s, p); > > else if (CONFIG_APNG_DECODER && > > - s->previous_picture.f->width == p->width && > > - s->previous_picture.f->height== p->height && > > - s->previous_picture.f->format== p->format && > > > > No explanation provided why those line are removed. > They are removed because previous_picture is removed. As is actually explained in the commit message. -- 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] [RFC] Event loop
James Almer (12021-02-01): > I support the idea of it being a build option (Perhaps simply > --enable-libev, like any other external dep). There's a precedent of > external libraries being used as backend for certain features, with the most > prominent example being libsoxr as the resample engine in libswresample. > > This of course as long as it's not autodetected, so FATE clients don't use > it. The last thing we want is the internal implementation being neglected > because all devs use libev. Thanks for the feedback. I agree with all this, although I suspect the "certain features" brought by libev would prove to be just a slight performance enhancement in extreme cases. But interacting with any event loop is a necessary feature, and as such it needs to be properly implemented and tested. Are there other remarks on this? Otherwise I shall start the code proper. 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".
[FFmpeg-devel] Interested in contributing to gsoc
Hello, I am Sanskar Khandelwal, a 3rd year undergrad student ,I am interested in contributing to ffmpeg and also participating in gsoc along with this year. I have a few questions if someone can answer them and help me get started it'll be nice. 1. Is this a right platform to ask questions, I saw most of the mail here is patch so which is the active platform irc or mailing list to ask project and gsoc related questions? 2. I think the first step is to choose a project but did not find any project list for this year, I don't know where to start so can anyone help me like how do I have to set up things in my laptop and suggest any issues for beginners so I can start and learn more about ffmpeg in mean time. 3. When can I expect the idea list for this year, also I looked for this in wiki so I am looking in the right place, right? thanks --sanskar ___ 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 4/6] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"
On Wed, Feb 17, 2021 at 12:31 PM Anton Khirnov wrote: > Quoting Paul B Mahol (2021-02-17 11:45:02) > > On Wed, Feb 17, 2021 at 9:14 AM Anton Khirnov wrote: > > > > > Quoting Paul B Mahol (2021-02-16 21:57:47) > > > > Do you have actual proof for such claims? > > > > > > The burden of proof is on you here - you are supposed to prove that > your > > > commit fixes something. And when I asked you about details, you > couldn't > > > even tell me what the bug was, much less why would switching the order > > > of allocations be the correct fix for it. > > > > > > > It is not about order of allocations. > > What is it about then? > > > > > > > > > > > > > > > > There is no point in reverting commit if that commit fixed some > behavior. > > > > > > It didn't fix anything though. Before your commit, frame 69 of the > > > sample in #9017 is almost black with 1 thread and looks okay with 2 > > > threads. After your commit, it is almost black in both cases. So your > > > commit made it consistently wrong. This shows up in my tests and is > also > > > > > > > > > You are mistaken. It fixed race. Prove it does not. > > You have it backwards. You are making a claim - that your patch fixes a > race. It is your responsibility to prove that your patch is correct. So > far you did not even explain what this supposed race is. > I'm loosing my precious time discussing irrelevant matters here. Is helgrind report clean with your patch set? > -- > 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 5/6] pngdec: fix and simplify apng reference handling
On Wed, Feb 17, 2021 at 12:33 PM Anton Khirnov wrote: > Quoting Paul B Mahol (2021-02-17 11:52:31) > > On Tue, Feb 16, 2021 at 9:26 PM Anton Khirnov wrote: > > > @@ -1088,23 +1084,23 @@ static int handle_p_frame_apng(AVCodecContext > > > *avctx, PNGDecContext *s, > > > if (!buffer) > > > return AVERROR(ENOMEM); > > > > > > +ff_thread_await_progress(&s->last_picture, INT_MAX, 0); > > > > > > -// Do the disposal operation specified by the last frame on the > frame > > > -if (s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) { > > > -ff_thread_await_progress(&s->last_picture, INT_MAX, 0); > > > -memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * > > > s->height); > > > - > > > -if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) > > > -for (y = s->last_y_offset; y < s->last_y_offset + > s->last_h; > > > ++y) > > > -memset(buffer + s->image_linesize * y + s->bpp * > > > s->last_x_offset, 0, s->bpp * s->last_w); > > > +// need to reset a rectangle to background: > > > +// create a new writable copy > > > +if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) { > > > +int ret = av_frame_make_writable(s->last_picture.f); > > > +if (ret < 0) > > > +return ret; > > > > > > -memcpy(s->previous_picture.f->data[0], buffer, > s->image_linesize > > > * s->height); > > > -ff_thread_report_progress(&s->previous_picture, INT_MAX, 0); > > > -} else { > > > -ff_thread_await_progress(&s->previous_picture, INT_MAX, 0); > > > -memcpy(buffer, s->previous_picture.f->data[0], > s->image_linesize > > > * s->height); > > > +for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; > y++) > > > { > > > +memset(s->last_picture.f->data[0] + s->image_linesize * y > + > > > + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); > > > +} > > > } > > > > > > +memcpy(buffer, s->last_picture.f->data[0], s->image_linesize * > > > s->height); > > > + > > > // Perform blending > > > if (s->blend_op == APNG_BLEND_OP_SOURCE) { > > > for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { > > > @@ -1448,22 +1444,17 @@ exit_loop: > > > if (CONFIG_PNG_DECODER && avctx->codec_id != > AV_CODEC_ID_APNG) > > > handle_p_frame_png(s, p); > > > else if (CONFIG_APNG_DECODER && > > > - s->previous_picture.f->width == p->width && > > > - s->previous_picture.f->height== p->height && > > > - s->previous_picture.f->format== p->format && > > > > > > > No explanation provided why those line are removed. > > > > They are removed because previous_picture is removed. As is actually > explained in the commit message. > > But you just replaced previous with last? > -- > Anton Khirnov > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec: add exr format parser
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/exr_parser.c | 217 libavcodec/parsers.c| 1 + 3 files changed, 219 insertions(+) create mode 100644 libavcodec/exr_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 5fb735f129..82d1f15b40 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1095,6 +1095,7 @@ OBJS-$(CONFIG_DVAUDIO_PARSER) += dvaudio_parser.o OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o +OBJS-$(CONFIG_EXR_PARSER) += exr_parser.o OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o OBJS-$(CONFIG_G729_PARSER) += g729_parser.o diff --git a/libavcodec/exr_parser.c b/libavcodec/exr_parser.c new file mode 100644 index 00..93833cd23d --- /dev/null +++ b/libavcodec/exr_parser.c @@ -0,0 +1,217 @@ +/* + * EXR parser + * Copyright (c) 2020 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * EXR parser + */ + +#include "libavutil/bswap.h" +#include "libavutil/intreadwrite.h" +#include "parser.h" + +typedef struct EXRParseContext { +ParseContext pc; + +int flags; +uint32_t w, h; +uint32_t tile_w, tile_h; +int64_t skip_bytes; +uint64_t bytes_read; +int nb_offsets; +unsigned curr_offset; +unsigned offset_index; +uint64_t max_offset; +int compression; + +int exr_state; +uint8_t key[256]; +unsigned key_index; +uint8_t type[256]; +unsigned type_index; +uint32_t size; +unsigned size_index; +uint8_t value[256]; +uint32_t value_index; +} EXRParseContext; + +static int exr_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ +EXRParseContext *exr = s->priv_data; +uint64_t state = exr->pc.state64; +int next = END_NOT_FOUND, i = 0; + +s->pict_type = AV_PICTURE_TYPE_I; +s->key_frame = 1; + +*poutbuf_size = 0; +*poutbuf = NULL; + +if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { +next = buf_size; +} else { +for (; i < buf_size; i++) { +exr->bytes_read++; +state = (state << 8) | buf[i]; + +if (exr->skip_bytes > 0 && exr->exr_state == 0) { +exr->skip_bytes--; +if (exr->skip_bytes == 0) { +next = i + 1; +exr->bytes_read = 0; +break; +} +} else if (exr->exr_state == 1) { +exr->key[exr->key_index++] = buf[i]; +if (exr->key_index >= 255) { +exr->exr_state = 0; +exr->key_index = 0; +memset(exr->key, 0, sizeof(exr->key)); +goto new_state; +} + +if (!buf[i] && exr->key_index == 1) { +exr->exr_state = 5; +if (!(exr->flags & 0x02)) { +switch (exr->compression) { +case 5: +case 3: +exr->nb_offsets = (exr->nb_offsets + 15) >> 4; +break; +case 4: +case 6: +case 7: +exr->nb_offsets = (exr->nb_offsets + 31) >> 5; +break; +default: +break; +} +} else if (exr->tile_w && exr->tile_h) { +exr->nb_offsets = ((exr->w + exr->tile_w - 1) / exr->tile_w) * +((exr->h + exr->tile_h - 1) / exr->tile_h); +} +exr->curr_offset = 0; +exr->offset_index = 0; +exr->max_offset = 0; +} else if (!buf[i]) { +exr->exr_state = 2; +} +
Re: [FFmpeg-devel] [RFC] Event loop
Feb 17, 2021, 12:47 by geo...@nsup.org: > James Almer (12021-02-01): > >> I support the idea of it being a build option (Perhaps simply >> --enable-libev, like any other external dep). There's a precedent of >> external libraries being used as backend for certain features, with the most >> prominent example being libsoxr as the resample engine in libswresample. >> >> This of course as long as it's not autodetected, so FATE clients don't use >> it. The last thing we want is the internal implementation being neglected >> because all devs use libev. >> > > Thanks for the feedback. I agree with all this, although I suspect > the "certain features" brought by libev would prove to be just a slight > performance enhancement in extreme cases. But interacting with any event > loop is a necessary feature, and as such it needs to be properly > implemented and tested. > > Are there other remarks on this? Otherwise I shall start the code > proper. > I think I'd prefer an asynchronous library rather than libev. So libuv? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] Event loop
Lynne (12021-02-17): > I think I'd prefer an asynchronous library rather than libev. > So libuv? I have on occasion straced node to debug things, and what I have observed is: I don't want to touch it even with a very long stick. Wan you explain more precisely why you think libuv would be a better choice than libev? 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".
[FFmpeg-devel] [PATCH 1/2] avcodec/mediacodec_wrapper: clean up ff_AMediaCodecList_getCodecNameByType a bit
Hi, while looking into mediacodec for unrelated reasons I saw some room for improvement. Therefore, here's a series with two small patches. >From cadd2b2d4a5ffbb4dcc34faf2d3e139e1d4d608b Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 11 Feb 2021 19:23:26 +0100 Subject: [PATCH 1/2] avcodec/mediacodec_wrapper: clean up ff_AMediaCodecList_getCodecNameByType a bit We can skip software decoders before even looking at the mime types. --- libavcodec/mediacodec_wrapper.c | 113 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index 79abc8b6aa..f1945bcfc0 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -441,6 +441,30 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e goto done_with_info; } +codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id); +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { +goto done; +} + +name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx); +if (!name) { +goto done; +} + +if (codec_name) { +(*env)->DeleteLocalRef(env, codec_name); +codec_name = NULL; +} + +/* Skip software decoders */ +if ( +strstr(name, "OMX.google") || +strstr(name, "OMX.ffmpeg") || +(strstr(name, "OMX.SEC") && strstr(name, ".sw.")) || +!strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) { +goto done_with_info; +} + type_count = (*env)->GetArrayLength(env, types); for (j = 0; j < type_count; j++) { int k; @@ -456,74 +480,51 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e goto done; } -if (!av_strcasecmp(supported_type, mime)) { -codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id); -if (ff_jni_exception_check(env, 1, log_ctx) < 0) { -goto done; -} +if (av_strcasecmp(supported_type, mime)) { +goto done_with_type; +} -name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx); -if (!name) { -goto done; -} +capabilities = (*env)->CallObjectMethod(env, info, jfields.get_codec_capabilities_id, type); +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { +goto done; +} -if (codec_name) { -(*env)->DeleteLocalRef(env, codec_name); -codec_name = NULL; -} +profile_levels = (*env)->GetObjectField(env, capabilities, jfields.profile_levels_id); +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { +goto done; +} -/* Skip software decoders */ -if ( -strstr(name, "OMX.google") || -strstr(name, "OMX.ffmpeg") || -(strstr(name, "OMX.SEC") && strstr(name, ".sw.")) || -!strcmp(name, "OMX.qcom.video.decoder.hevcswvdec")) { -av_freep(&name); -goto done_with_type; +profile_count = (*env)->GetArrayLength(env, profile_levels); +if (!profile_count) { +found_codec = 1; +} +for (k = 0; k < profile_count; k++) { +int supported_profile = 0; + +if (profile < 0) { +found_codec = 1; +break; } -capabilities = (*env)->CallObjectMethod(env, info, jfields.get_codec_capabilities_id, type); +profile_level = (*env)->GetObjectArrayElement(env, profile_levels, k); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } -profile_levels = (*env)->GetObjectField(env, capabilities, jfields.profile_levels_id); +supported_profile = (*env)->GetIntField(env, profile_level, jfields.profile_id); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; } -profile_count = (*env)->GetArrayLength(env, profile_levels); -if (!profile_count) { -found_codec = 1; +found_codec = profile == supported_profile; + +if (profile_level) { +(*env)->DeleteLocalRef(env, profile_level); +profile_level = NULL; } -for (k = 0; k < profile_count; k++) { -int supported_profile = 0; - -if (profile < 0) { -
[FFmpeg-devel] [PATCH 2/2] avcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available
>From 22ebde779f61fb030633a881ef320264ea446b6b Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 11 Feb 2021 20:48:54 +0100 Subject: [PATCH 2/2] avcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available Added in Android 10 it provides a reliable way of filtering out software decoders, unlike existing string-based checks. --- libavcodec/mediacodec_wrapper.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index f1945bcfc0..c829941d6b 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -45,6 +45,7 @@ struct JNIAMediaCodecListFields { jmethodID get_codec_capabilities_id; jmethodID get_supported_types_id; jmethodID is_encoder_id; +jmethodID is_software_only_id; jclass codec_capabilities_class; jfieldID color_formats_id; @@ -81,6 +82,7 @@ static const struct FFJniField jni_amediacodeclist_mapping[] = { { "android/media/MediaCodecInfo", "getCapabilitiesForType", "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_capabilities_id), 1 }, { "android/media/MediaCodecInfo", "getSupportedTypes", "()[Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_supported_types_id), 1 }, { "android/media/MediaCodecInfo", "isEncoder", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_encoder_id), 1 }, +{ "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_software_only_id), 0 }, { "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, codec_capabilities_class), 1 }, { "android/media/MediaCodecInfo$CodecCapabilities", "colorFormats", "[I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, color_formats_id), 1 }, @@ -441,6 +443,17 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e goto done_with_info; } +if (jfields.is_software_only_id) { +int is_software_only = (*env)->CallBooleanMethod(env, info, jfields.is_software_only_id); +if (ff_jni_exception_check(env, 1, log_ctx) < 0) { +goto done; +} + +if (is_software_only) { +goto done_with_info; +} +} + codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id); if (ff_jni_exception_check(env, 1, log_ctx) < 0) { goto done; -- 2.30.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] Fix test for complete frame in MxPEG decoder
Hi, I've noticed that the MxPEG decoder fails to read a video stream if the bitmask used to track updated blocks has a length which is not a multiple of 8. The attached patch provides a tentative fix. Best, Gabriele 0001-Fix-test-for-complete-frame-in-MxPEG-decoder.patch Description: Binary data ___ 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] x86/vf_gblur: fix postscale_slice prologue
x86_32 ABI does not pass float arguments directly on xmm regs, and the Win64 ABI uses only the first four regs for this purpose. Signed-off-by: James Almer --- libavfilter/vf_gblur.c | 3 +-- libavfilter/x86/vf_gblur.asm | 29 + 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c index 109a7a95f9..40956e122d 100644 --- a/libavfilter/vf_gblur.c +++ b/libavfilter/vf_gblur.c @@ -234,8 +234,7 @@ void ff_gblur_init(GBlurContext *s) { s->horiz_slice = horiz_slice_c; s->postscale_slice = postscale_c; -if (ARCH_X86_64) -ff_gblur_init_x86(s); +ff_gblur_init_x86(s); } static int config_input(AVFilterLink *inlink) diff --git a/libavfilter/x86/vf_gblur.asm b/libavfilter/x86/vf_gblur.asm index c29ecba889..c2b2998202 100644 --- a/libavfilter/x86/vf_gblur.asm +++ b/libavfilter/x86/vf_gblur.asm @@ -185,27 +185,24 @@ HORIZ_SLICE %endif %macro POSTSCALE_SLICE 0 -%if UNIX64 -cglobal postscale_slice, 2, 2, 4, ptr, length -%else -cglobal postscale_slice, 5, 5, 4, ptr, length, postscale, min, max -%endif +cglobal postscale_slice, 2, 2, 4, ptr, length, postscale, min, max shl lengthd, 2 add ptrq, lengthq neg lengthq -%if WIN64 +%if ARCH_X86_32 +VBROADCASTSS m0, postscalem +VBROADCASTSS m1, minm +VBROADCASTSS m2, maxm +%elif WIN64 SWAP 0, 2 SWAP 1, 3 -SWAP 2, 4 -%endif -%if cpuflag(avx2) -vbroadcastss m0, xm0 -vbroadcastss m1, xm1 -vbroadcastss m2, xm2 -%else -shufps xm0, xm0, 0 -shufps xm1, xm1, 0 -shufps xm2, xm2, 0 +VBROADCASTSS m0, xm0 +VBROADCASTSS m1, xm1 +VBROADCASTSS m2, maxm +%else ; UNIX64 +VBROADCASTSS m0, xm0 +VBROADCASTSS m1, xm1 +VBROADCASTSS m2, xm3 %endif .loop: -- 2.30.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] checkasm/vf_gblur: add a test for postscale_slice
Signed-off-by: James Almer --- tests/checkasm/vf_gblur.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/tests/checkasm/vf_gblur.c b/tests/checkasm/vf_gblur.c index 8ff47a338f..b9fe2f9a36 100644 --- a/tests/checkasm/vf_gblur.c +++ b/tests/checkasm/vf_gblur.c @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include #include "checkasm.h" #include "libavfilter/gblur.h" @@ -48,6 +49,19 @@ static void check_horiz_slice(float *dst_ref, float *dst_new) bench_new(dst_new, WIDTH, HEIGHT, 1, nu, bscale); } +static void check_postscale_slice(float *dst_ref, float *dst_new) +{ +float postscale = 0.0603f; + +declare_func(void, float *dst, int len, float postscale, float min, float max); +call_ref(dst_ref, PIXELS, postscale, -FLT_MAX, FLT_MAX); +call_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX); +if (!float_near_abs_eps_array(dst_ref, dst_new, FLT_EPSILON, PIXELS)) { +fail(); +} +bench_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX); +} + void checkasm_check_vf_gblur(void) { float *dst_ref = av_malloc(BUF_SIZE); @@ -63,6 +77,14 @@ void checkasm_check_vf_gblur(void) check_horiz_slice(dst_ref, dst_new); } report("horiz_slice"); + +randomize_buffers(dst_ref, PIXELS); +memcpy(dst_new, dst_ref, BUF_SIZE); +if (check_func(s.postscale_slice, "postscale_slice")) { +check_postscale_slice(dst_ref, dst_new); +} +report("postscale_slice"); + av_freep(&dst_ref); av_freep(&dst_new); } -- 2.30.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] x86/vf_gblur: fix postscale_slice prologue
lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] checkasm/vf_gblur: add a test for postscale_slice
probably ok if tested ___ 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] avcodec/libvpxenc: fix potential memory leak.
Hi Nicolas, On Wed, Feb 17, 2021 at 3:00 AM Nicolas George wrote: > Wonkap Jang (12021-02-16): > > While parsing ref_frame_config, AVdictionary needs to be manually > > deallocated. > > --- > > libavcodec/libvpxenc.c | 19 --- > > 1 file changed, 12 insertions(+), 7 deletions(-) > > NAK. > > This code is all wrong, it looks like Java or Python, it should not be > using a dictionary in the first place, even less a dictionary stored in > the context. Just iterate over the key=value pairs of the string without > allocating all of them longer than necessary. > > 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". I'll change it to use a local variable. But, not sure what you mean by "not using the dictionary in the first place".. Could you explain how to do this? I need to parse multiple variables that have multiple values that have variable number of entries depending on th enumber of spatial layers. I appreciate your help. Thank you, Wonkap ___ 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] avcodec/libvpxenc: fix potential memory leak.
On Wed, Feb 17, 2021 at 8:52 AM Wonkap Jang wrote: > Hi Nicolas, > > On Wed, Feb 17, 2021 at 3:00 AM Nicolas George wrote: > >> Wonkap Jang (12021-02-16): >> > While parsing ref_frame_config, AVdictionary needs to be manually >> > deallocated. >> > --- >> > libavcodec/libvpxenc.c | 19 --- >> > 1 file changed, 12 insertions(+), 7 deletions(-) >> >> NAK. >> >> This code is all wrong, it looks like Java or Python, it should not be >> using a dictionary in the first place, even less a dictionary stored in >> the context. Just iterate over the key=value pairs of the string without >> allocating all of them longer than necessary. >> >> 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". > > > I'll change it to use a local variable. > > But, not sure what you mean by "not using the dictionary in the first > place".. > Could you explain how to do this? I need to parse multiple variables that > have multiple values that have variable number of entries depending on th > enumber of spatial layers. > > I appreciate your help. > > Thank you, > > Wonkap > > Or are you saying after getting the string with en->value, I should just parse through the string without dictionary? Not quite familiar with using AVDictionary.. My purpose here is not to envoke av_dict_set for each parameter, but rather get all parameters in one call (using "ref-frame-config"), and parse through each parameter internally. And, in order to do that, I had to parse the whole string into a key-value pairs, and then recurse through them. Thanks, -Wonkap ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] checkasm/vf_gblur: add a test for postscale_slice
On 2/17/2021 1:47 PM, Paul B Mahol wrote: probably ok if tested Set pushed. Thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/cfhd: Fix negative shift in cfhd_decode()
Fixes: left shift of negative value -1 Fixes: 30714/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4867823371419648 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/cfhd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index dfd56ae6ed..1f2ee853c1 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -811,7 +811,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, const uint16_t q = s->quantisation; for (i = 0; i < run; i++) { -*coeff_data |= coeff << 8; +*coeff_data |= coeff * 256; *coeff_data++ *= q; } } else { @@ -842,7 +842,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, const uint16_t q = s->quantisation; for (i = 0; i < run; i++) { -*coeff_data |= coeff << 8; +*coeff_data |= coeff * 256; *coeff_data++ *= q; } } else { -- 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 v3] avcodec/libvpxenc: fix potential memory leak.
While parsing ref_frame_config, AVdictionary needs to be manually deallocated. --- libavcodec/libvpxenc.c | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 284cb9a108..56a1b5aafe 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -127,7 +127,6 @@ typedef struct VPxEncoderContext { int roi_warned; #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) vpx_svc_ref_frame_config_t ref_frame_config; -AVDictionary *vpx_ref_frame_config; #endif } VPxContext; @@ -1595,15 +1594,21 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, if (en) { if (avctx->codec_id == AV_CODEC_ID_VP9) { AVDictionaryEntry* en2 = NULL; -av_dict_parse_string(&ctx->vpx_ref_frame_config, en->value, "=", ":", 0); - -while ((en2 = av_dict_get(ctx->vpx_ref_frame_config, "", en2, AV_DICT_IGNORE_SUFFIX))) { -if (vpx_ref_frame_config_parse(ctx, enccfg, en2->key, en2->value, avctx->codec_id) < 0) -av_log(avctx, AV_LOG_WARNING, - "Error parsing option '%s = %s'.\n", - en2->key, en2->value); +AVDictionary* vpx_ref_frame_config = NULL; + +if (av_dict_parse_string(&vpx_ref_frame_config, en->value, "=", ":", 0) != 0) { +av_log(avctx, AV_LOG_WARNING, + "Error in parsing ref-frame-config. \n"); +} else { +while ((en2 = av_dict_get(vpx_ref_frame_config, "", en2, AV_DICT_IGNORE_SUFFIX))) { +if (vpx_ref_frame_config_parse(ctx, enccfg, en2->key, en2->value, avctx->codec_id) < 0) +av_log(avctx, AV_LOG_WARNING, + "Error parsing option '%s = %s'.\n", + en2->key, en2->value); +} } +av_dict_free(&vpx_ref_frame_config); codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (int *)&ctx->ref_frame_config); } else { av_log(avctx, AV_LOG_WARNING, -- 2.30.0.478.g8a0d178c01-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".
Re: [FFmpeg-devel] [PATCH v3] avcodec/libvpxenc: fix potential memory leak.
Wonkap Jang (12021-02-17): > Or are you saying after getting the string with en->value, I should just > parse through the string without dictionary? Yes, exactly. You would use a dictionary if you need to keep all the values for a later use. But in this case, there is no later use, you only iterate on the values once, and immediately. > My purpose here is not to envoke av_dict_set for each parameter, but rather > get all parameters in one call (using "ref-frame-config"), and parse > through each parameter internally. And, in order to do that, I had to parse > the whole string into a key-value pairs, and then recurse through them. Yes, that is the "simple" way to do it, when you use a high-level language and do not worry about optimizations: use a high-level function, store into a high-level data structure, then use a high-level construct to exploit that data structure. But FFmpeg is low-level and cares about optimization. So you use a low-level parsing function, and do the strict necessary to achieve the result. The code should look like: loop parse one pair check for error and return stop if it's the end do with the pair free the pair end loop I suggest you look at the code for av_dict_parse_string() if this does not seem easy to you (it should!) or if you are not familiar with the other helper function available. Your code will be similar, but instead of av_dict_set(), you do the libvpx stuff. 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 v3] avcodec/libvpxenc: fix potential memory leak.
Wonkap Jang (12021-02-17): > While parsing ref_frame_config, AVdictionary needs to be manually > deallocated. > --- > libavcodec/libvpxenc.c | 21 + > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index 284cb9a108..56a1b5aafe 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -127,7 +127,6 @@ typedef struct VPxEncoderContext { > int roi_warned; > #if CONFIG_LIBVPX_VP9_ENCODER && > defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > vpx_svc_ref_frame_config_t ref_frame_config; > -AVDictionary *vpx_ref_frame_config; > #endif > } VPxContext; > > @@ -1595,15 +1594,21 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket > *pkt, > if (en) { > if (avctx->codec_id == AV_CODEC_ID_VP9) { > AVDictionaryEntry* en2 = NULL; > -av_dict_parse_string(&ctx->vpx_ref_frame_config, > en->value, "=", ":", 0); > - > -while ((en2 = av_dict_get(ctx->vpx_ref_frame_config, "", > en2, AV_DICT_IGNORE_SUFFIX))) { > -if (vpx_ref_frame_config_parse(ctx, enccfg, > en2->key, en2->value, avctx->codec_id) < 0) > -av_log(avctx, AV_LOG_WARNING, > - "Error parsing option '%s = %s'.\n", > - en2->key, en2->value); > +AVDictionary* vpx_ref_frame_config = NULL; > + > +if (av_dict_parse_string(&vpx_ref_frame_config, > en->value, "=", ":", 0) != 0) { > +av_log(avctx, AV_LOG_WARNING, > + "Error in parsing ref-frame-config. \n"); I forgot this the first time: the error must be forwarded. > +} else { > +while ((en2 = av_dict_get(vpx_ref_frame_config, "", > en2, AV_DICT_IGNORE_SUFFIX))) { > +if (vpx_ref_frame_config_parse(ctx, enccfg, > en2->key, en2->value, avctx->codec_id) < 0) > +av_log(avctx, AV_LOG_WARNING, > + "Error parsing option '%s = %s'.\n", > + en2->key, en2->value); > +} See my other mail: it should not be in a dictionary at all, just passing the string and using the values immediately. > } > > +av_dict_free(&vpx_ref_frame_config); > codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (int > *)&ctx->ref_frame_config); > } else { > av_log(avctx, AV_LOG_WARNING, 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 1/3] x86/vf_gblur: fix postscale_slice prologue
On Wed, Feb 17, 2021 at 01:41:04PM -0300, James Almer wrote: > x86_32 ABI does not pass float arguments directly on xmm regs, and the Win64 > ABI uses only the first four regs for this purpose. > > Signed-off-by: James Almer > --- > libavfilter/vf_gblur.c | 3 +-- > libavfilter/x86/vf_gblur.asm | 29 + > 2 files changed, 14 insertions(+), 18 deletions(-) > > diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c > index 109a7a95f9..40956e122d 100644 > --- a/libavfilter/vf_gblur.c > +++ b/libavfilter/vf_gblur.c > @@ -234,8 +234,7 @@ void ff_gblur_init(GBlurContext *s) > { > s->horiz_slice = horiz_slice_c; > s->postscale_slice = postscale_c; > -if (ARCH_X86_64) > -ff_gblur_init_x86(s); > +ff_gblur_init_x86(s); > } fails on arm LD ffmpeg_g libavfilter/libavfilter.a(vf_gblur.o): In function `ff_gblur_init': arm/src/libavfilter/vf_gblur.c:237: undefined reference to `ff_gblur_init_x86' arm/src/libavfilter/vf_gblur.c:237: undefined reference to `ff_gblur_init_x86' collect2: error: ld returned 1 exit status Makefile:124: recipe for target 'ffmpeg_g' failed make: *** [ffmpeg_g] Error 1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] x86/vf_gblur: fix postscale_slice prologue
On 2/17/2021 3:34 PM, Michael Niedermayer wrote: On Wed, Feb 17, 2021 at 01:41:04PM -0300, James Almer wrote: x86_32 ABI does not pass float arguments directly on xmm regs, and the Win64 ABI uses only the first four regs for this purpose. Signed-off-by: James Almer --- libavfilter/vf_gblur.c | 3 +-- libavfilter/x86/vf_gblur.asm | 29 + 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c index 109a7a95f9..40956e122d 100644 --- a/libavfilter/vf_gblur.c +++ b/libavfilter/vf_gblur.c @@ -234,8 +234,7 @@ void ff_gblur_init(GBlurContext *s) { s->horiz_slice = horiz_slice_c; s->postscale_slice = postscale_c; -if (ARCH_X86_64) -ff_gblur_init_x86(s); +ff_gblur_init_x86(s); } fails on arm LD ffmpeg_g libavfilter/libavfilter.a(vf_gblur.o): In function `ff_gblur_init': arm/src/libavfilter/vf_gblur.c:237: undefined reference to `ff_gblur_init_x86' arm/src/libavfilter/vf_gblur.c:237: undefined reference to `ff_gblur_init_x86' collect2: error: ld returned 1 exit status Makefile:124: recipe for target 'ffmpeg_g' failed make: *** [ffmpeg_g] Error 1 Fixed, sorry about that. ___ 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] GSoC 2021
On Tue, Feb 02, 2021 at 10:48:13AM +0100, Michael Niedermayer wrote: > Hi all > > Most people probably already know but just to be sure everyone knows > GSoC 2021 is 175h not 350h > https://groups.google.com/g/google-summer-of-code-discuss/c/GgvbLrFBcUQ?pli=1 > > Some project ideas may need to be adjusted accordingly So far FFmpegs gsoc 2021 Project Ideas page list is quite long, it has 0 ideas. Please help changing that, otherwise FFmpeg might be rejected by google this year. For reference: https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2021 Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Freedom in capitalist society always remains about the same as it was in ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org 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] libsvtav1: Add logical_processors option
On Sun, Feb 14, 2021 at 12:27 PM Christopher Degawa wrote: > That said, if you have a general use-case where this is helpful and the >> documentation explains what it is doing (and warns about the bad cases) >> then maybe? >> > > The main use case we have internally is to able to run multiple instances > of SvtAv1EncApp with `--lp 1` without worrying about potentially choking > out all of them and also for testing for potential single versus multi-core > issues. Also, it seems my wording was wrong and it's not to "certain CPUs", > but to a "certain number of CPUs" > Another usage for this option would be to limit the amount of memory used as right now the ram usage is tied to the numbers of cores used. ___ 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] libavformat/dashenc.c: In some circumstances a total_duration equals to zero so that it makes possible for SIGFPE to appear and crash an application.
--- libavformat/dashenc.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 2d757b3a87..fbdee126e9 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -844,7 +844,11 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind if (os->bit_rate > 0) snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", os->bit_rate); else if (final) { -int average_bit_rate = os->pos * 8 * AV_TIME_BASE / c->total_duration; +int average_bit_rate = 0; +if(c->total_duration > 0) +{ +average_bit_rate = os->pos * 8 * AV_TIME_BASE / c->total_duration; +} snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", average_bit_rate); } else if (os->first_segment_bit_rate > 0) snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", os->first_segment_bit_rate); -- 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".
Re: [FFmpeg-devel] Interested in contributing to gsoc
Hello Sanskar On Wed, Feb 17, 2021 at 06:54:05PM +0530, Sanskar Khandelwal wrote: > Hello, > > I am Sanskar Khandelwal, a 3rd year undergrad student ,I am interested in > contributing to ffmpeg and also participating in gsoc along with this year. > I have a few questions if someone can answer them and help me get started > it'll be nice. > > 1. Is this a right platform to ask questions, I saw most of the mail here > is patch so which is the active platform irc or mailing list to ask project > and gsoc related questions? both the ML here and IRC are equally right for project and gsoc related questions > > 2. I think the first step is to choose a project but did not find any > project list for this year, I don't know where to start so can anyone help > me like how do I have to set up things in my laptop and suggest any issues > for beginners so I can start and learn more about ffmpeg in mean time. If you havnt yet, setup what you need to fetch and build FFmpeg (git, c compiler, ...) get ffmpeg from git, build it and then do something with it thats interresting to you. Maybe look at our bug tracker if you can find some bug you want to try to fix. Thats a good way for you to find out if you like working on FFmpegs codebase > > 3. When can I expect the idea list for this year, also I looked for this in > wiki so I am looking in the right place, right? It should be there: but its ATM listing too few ideas https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2021 you can also look at previous years lists but keep in mind this year google decided to shorten the time so previous years project ideas might be too much. Thats also why we are a bit behind with the list we need new or adapted ideas for this year. Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] checkasm/vf_gblur: split off the horiz_slice test into its own function
Will come in handy for the following commit. Signed-off-by: James Almer --- tests/checkasm/vf_gblur.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/checkasm/vf_gblur.c b/tests/checkasm/vf_gblur.c index 1d63fc22a0..8ff47a338f 100644 --- a/tests/checkasm/vf_gblur.c +++ b/tests/checkasm/vf_gblur.c @@ -33,18 +33,26 @@ tmp_buf[j] = (float)(rnd() & 0xFF); \ } while (0) -void checkasm_check_vf_gblur(void) +static void check_horiz_slice(float *dst_ref, float *dst_new) { -float *dst_ref = av_malloc(BUF_SIZE); -float *dst_new = av_malloc(BUF_SIZE); -int w = WIDTH; -int h = HEIGHT; int steps = 2; float nu = 0.101f; float bscale = 1.112f; -GBlurContext s; declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale); +call_ref(dst_ref, WIDTH, HEIGHT, steps, nu, bscale); +call_new(dst_new, WIDTH, HEIGHT, steps, nu, bscale); +if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) { + fail(); +} +bench_new(dst_new, WIDTH, HEIGHT, 1, nu, bscale); +} + +void checkasm_check_vf_gblur(void) +{ +float *dst_ref = av_malloc(BUF_SIZE); +float *dst_new = av_malloc(BUF_SIZE); +GBlurContext s; randomize_buffers(dst_ref, PIXELS); memcpy(dst_new, dst_ref, BUF_SIZE); @@ -52,13 +60,7 @@ void checkasm_check_vf_gblur(void) ff_gblur_init(&s); if (check_func(s.horiz_slice, "horiz_slice")) { -call_ref(dst_ref, w, h, steps, nu, bscale); -call_new(dst_new, w, h, steps, nu, bscale); - -if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) { -fail(); -} -bench_new(dst_new, w, h, 1, nu, bscale); +check_horiz_slice(dst_ref, dst_new); } report("horiz_slice"); av_freep(&dst_ref); -- 2.30.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3] avcodec/libvpxenc: fix potential memory leak.
On Wed, Feb 17, 2021 at 9:50 AM Nicolas George wrote: > Wonkap Jang (12021-02-17): > > While parsing ref_frame_config, AVdictionary needs to be manually > > deallocated. > > --- > > libavcodec/libvpxenc.c | 21 + > > 1 file changed, 13 insertions(+), 8 deletions(-) > > > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > > index 284cb9a108..56a1b5aafe 100644 > > --- a/libavcodec/libvpxenc.c > > +++ b/libavcodec/libvpxenc.c > > @@ -127,7 +127,6 @@ typedef struct VPxEncoderContext { > > int roi_warned; > > #if CONFIG_LIBVPX_VP9_ENCODER && > defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) > > vpx_svc_ref_frame_config_t ref_frame_config; > > -AVDictionary *vpx_ref_frame_config; > > #endif > > } VPxContext; > > > > @@ -1595,15 +1594,21 @@ static int vpx_encode(AVCodecContext *avctx, > AVPacket *pkt, > > if (en) { > > if (avctx->codec_id == AV_CODEC_ID_VP9) { > > AVDictionaryEntry* en2 = NULL; > > -av_dict_parse_string(&ctx->vpx_ref_frame_config, > en->value, "=", ":", 0); > > - > > -while ((en2 = > av_dict_get(ctx->vpx_ref_frame_config, "", en2, AV_DICT_IGNORE_SUFFIX))) { > > -if (vpx_ref_frame_config_parse(ctx, enccfg, > en2->key, en2->value, avctx->codec_id) < 0) > > -av_log(avctx, AV_LOG_WARNING, > > - "Error parsing option '%s = %s'.\n", > > - en2->key, en2->value); > > > +AVDictionary* vpx_ref_frame_config = NULL; > > + > > +if (av_dict_parse_string(&vpx_ref_frame_config, > en->value, "=", ":", 0) != 0) { > > > +av_log(avctx, AV_LOG_WARNING, > > + "Error in parsing ref-frame-config. \n"); > > I forgot this the first time: the error must be forwarded. > > > +} else { > > +while ((en2 = av_dict_get(vpx_ref_frame_config, > "", en2, AV_DICT_IGNORE_SUFFIX))) { > > +if (vpx_ref_frame_config_parse(ctx, enccfg, > en2->key, en2->value, avctx->codec_id) < 0) > > +av_log(avctx, AV_LOG_WARNING, > > + "Error parsing option '%s = > %s'.\n", > > + en2->key, en2->value); > > +} > > See my other mail: it should not be in a dictionary at all, just passing > the string and using the values immediately. > > > } > > > > +av_dict_free(&vpx_ref_frame_config); > > codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, > (int *)&ctx->ref_frame_config); > > } else { > > av_log(avctx, AV_LOG_WARNING, > > 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". Hi Nicolas, Thank you for the detailed information/recommendation. I do appreciate it. I always tend to use the available (already-tested) tools when it comes to string parsing due to potential errors that can easily pop up when dealing with string manipulations in C. And, if I were the owner of a project, I'd always recommend using exactly that even at the expense of losing a small (I think this is very small in my opinion) efficiency. I feel the things you will be saving would be some flag checking, and the part that is iterating through the parsed key-value pairs at the expense of losing the robustness of the code. And besides, the cost of the savings would be negligible compared to the whole encoding pipeline. I tend to forgive small loss of efficiency in complexity in encoding (external to codec) when it is not at the block (macroblock, CTU... etc.) level for the sake of robustness. That said, it is true that you will save some memory on top of the complexity, and the tiny inefficiencies do pile on to become unbearable sometimes. So, I will give it a shot. I'll look for the lower-level helper functions that are available as you suggested. Thank you so much, Wonkap ___ 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: add Simbiosis IMX demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/imx.c| 160 +++ 3 files changed, 162 insertions(+) create mode 100644 libavformat/imx.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 7bbf000cdc..e4d1f82c78 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -504,6 +504,7 @@ OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o OBJS-$(CONFIG_SER_DEMUXER) += serdec.o OBJS-$(CONFIG_SHORTEN_DEMUXER) += shortendec.o rawdec.o OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o +OBJS-$(CONFIG_SIMBIOSIS_IMX_DEMUXER) += imx.o OBJS-$(CONFIG_SINGLEJPEG_MUXER) += rawenc.o OBJS-$(CONFIG_SLN_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index f837ddabc8..3b69423508 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -403,6 +403,7 @@ extern AVOutputFormat ff_stream_segment_muxer; extern AVInputFormat ff_ser_demuxer; extern AVInputFormat ff_shorten_demuxer; extern AVInputFormat ff_siff_demuxer; +extern AVInputFormat ff_simbiosis_imx_demuxer; extern AVOutputFormat ff_singlejpeg_muxer; extern AVInputFormat ff_sln_demuxer; extern AVInputFormat ff_smacker_demuxer; diff --git a/libavformat/imx.c b/libavformat/imx.c new file mode 100644 index 00..66f18177a5 --- /dev/null +++ b/libavformat/imx.c @@ -0,0 +1,160 @@ +/* + * Simbiosis game demuxer + * + * Copyright (C) 2021 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/avassert.h" +#include "libavutil/internal.h" +#include "argo_asf.h" + +#define IMX_TAG MKTAG('I', 'M', 'A', 'X') + +typedef struct SimbiosisIMXDemuxContext { +uint8_t pal[AVPALETTE_SIZE]; +int pal_changed; +} SimbiosisIMXDemuxContext; + +static int simbiosis_imx_probe(const AVProbeData *p) +{ +if (AV_RL32(p->buf) != IMX_TAG) +return 0; +if (AV_RN32(p->buf+4) == 0) +return 0; +if (AV_RN16(p->buf+8) == 0) +return 0; +if (AV_RL16(p->buf+10) != 0x102) +return 0; + +return AVPROBE_SCORE_EXTENSION + 10; +} + +static int simbiosis_imx_read_header(AVFormatContext *s) +{ +AVIOContext *pb = s->pb; +AVStream *vst, *ast; +int rate; + +vst = avformat_new_stream(s, NULL); +ast = avformat_new_stream(s, NULL); +if (!vst || !ast) +return AVERROR(ENOMEM); + +avio_skip(pb, 4); + +vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; +vst->codecpar->codec_tag = 0; +vst->codecpar->format = AV_PIX_FMT_PAL8; +vst->codecpar->codec_id = AV_CODEC_ID_SIMBIOSIS_IMX; +vst->start_time = 0; +vst->nb_frames = avio_rl32(pb); +rate = avio_rl16(pb); +avio_skip(pb, 12); + +avpriv_set_pts_info(vst, 64, 1, rate); + +ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; +ast->codecpar->codec_tag = 0; +ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8; +ast->codecpar->channels = 1; +ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO; +ast->codecpar->sample_rate = 22050; +ast->start_time = 0; + +avpriv_set_pts_info(ast, 64, 1, 22050); + +return 0; +} + +static int simbiosis_imx_read_packet(AVFormatContext *s, AVPacket *pkt) +{ +AVIOContext *pb = s->pb; +SimbiosisIMXDemuxContext *imx = s->priv_data; +uint32_t chunk_size, chunk_type; +int64_t pos = avio_tell(pb); +int ret, idx = -1; + +retry: +if (avio_feof(pb)) +return AVERROR_EOF; + +chunk_size = avio_rl32(pb); +chunk_type = avio_rl32(pb); + +switch (chunk_type) { +case 0xAAFF: +return AVERROR_EOF; +case 0xAA99: +idx = 1; +break; +case 0xAA97: +idx = 0; +break; +case 0xAA98: +for (int i = 0; i < chunk_size / 3; i++) { +unsigned r = avio_r8(pb) << 18; +unsigned g = avio_r8(pb) << 10; +unsigned b = avio_r8(pb) << 2; + +AV_WL32(imx->pal + i * 4, (0xFFU << 24) | r | g | b); +} +imx->pal_changed = 1; +idx = -1;
[FFmpeg-devel] [PATCH 1/2] avcodec: add Simbiosis IMX video decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/imx.c| 153 5 files changed, 163 insertions(+) create mode 100644 libavcodec/imx.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 82d1f15b40..6a57ddf2b1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -620,6 +620,7 @@ OBJS-$(CONFIG_SIPR_DECODER)+= sipr.o acelp_pitch_delay.o \ acelp_filters.o celp_filters.o \ sipr16k.o OBJS-$(CONFIG_SIREN_DECODER) += siren.o +OBJS-$(CONFIG_SIMBIOSIS_IMX_DECODER) += imx.o OBJS-$(CONFIG_SMACKAUD_DECODER)+= smacker.o OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o OBJS-$(CONFIG_SMC_DECODER) += smc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index cb3f0e7c18..354d146379 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -293,6 +293,7 @@ extern AVCodec ff_sgi_encoder; extern AVCodec ff_sgi_decoder; extern AVCodec ff_sgirle_decoder; extern AVCodec ff_sheervideo_decoder; +extern AVCodec ff_simbiosis_imx_decoder; extern AVCodec ff_smacker_decoder; extern AVCodec ff_smc_decoder; extern AVCodec ff_smvjpeg_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index a7594f9004..8e695b11d2 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1842,6 +1842,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Cintel RAW"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, }, +{ +.id= AV_CODEC_ID_SIMBIOSIS_IMX, +.type = AVMEDIA_TYPE_VIDEO, +.name = "simbiosis_imx", +.long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"), +.props = AV_CODEC_PROP_LOSSY, +}, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 7a8a896bfe..56a69cf1c2 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -305,6 +305,7 @@ enum AVCodecID { AV_CODEC_ID_IPU, AV_CODEC_ID_ARGO, AV_CODEC_ID_CRI, +AV_CODEC_ID_SIMBIOSIS_IMX, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/imx.c b/libavcodec/imx.c new file mode 100644 index 00..1552a4ebea --- /dev/null +++ b/libavcodec/imx.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2021 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" + +typedef struct SimbiosisIMXContext { +uint32_t pal[256]; +uint8_t history[32768]; +int pos; +} SimbiosisIMXContext; + +static av_cold int imx_decode_init(AVCodecContext *avctx) +{ +avctx->pix_fmt = AV_PIX_FMT_PAL8; +avctx->width = 320; +avctx->height = 160; +return 0; +} + +static int imx_decode_frame(AVCodecContext *avctx, void *data, +int *got_frame, AVPacket *avpkt) +{ +SimbiosisIMXContext *imx = avctx->priv_data; +int ret, x, y, pal_size; +const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); +AVFrame *frame = data; +GetByteContext gb; + +if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) +return ret; + +if (pal && pal_size == AVPALETTE_SIZE) { +memcpy(imx->pal, pal, pal_size); +frame->palette_has_changed = 1; +} + +bytestream2_init(&gb, avpkt->data, avpkt->size); + +memcpy(frame->data[1], imx->pal, AVPALETTE_SIZE); + +x = 0, y = 0; +while (bytestream2_get_bytes_left(&gb) > 0 && + x < 320 && y < 160) { +int b = bytestream2_get_byte(&gb); +int len = b & 0x3f; +int op = b >> 6; +int fill; + +switch (op) { +case 3: +len = len * 64 + bytestream2_get_byte(&gb); +case 0: +while (len > 0) { +x++; +len--; +
Re: [FFmpeg-devel] [PATCH] avcodec: add initial exr image encoder
Will apply with these issues fixed soon. ___ 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] GSoC 2020 results page
Hi all If you mentored a project in 2020, please fill the results on the results page https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2020/Results Its empty ATM and previous years it was filled If you where a student of 2020 you can of course fill in your projects results too :) also anyone who want to help fill this is of course welcome to help too! Thank you -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "I am not trying to be anyone's saviour, I'm trying to think about the future and not be sad" - Elon Musk 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] Moves yuv2yuvX_sse3 to yasm, unrolls main loop and other small optimizations for ~20% speedup.
On Tue, Feb 16, 2021 at 6:31 PM Alan Kelly < alankelly-at-google@ffmpeg.org> wrote: > Looks like there are no comments, is this OK to be applied? Thanks > Applied, thanks for pinging. > > On Tue, Feb 9, 2021 at 6:25 PM Paul B Mahol wrote: > > > Will apply in no comments. > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] Event loop
On 01/02/2021 19:14, Nicolas George wrote: Based on this discussion, I say that the need for an event loop is confirmed. I will now start discussing actual plans for going forward. Since the coding work will be significant and not incremental, I want the outcome of this discussion to be binding: if we agree to do it a certain way, then the code for doing it will be accepted, pending code quality or new unforeseen issues. If anybody objects to this, please explain your reasons. First, again: Why we need an event loop. We need an event loop because we already have several ones. We already have five protocols and two devices implementing their own event loops. Factoring this duplicated code and implementing it properly is just the obvious way forward. Plus, it makes implementing new protocols simpler, especially when they are somewhat complex. And it can make applications simpler. So, my plan. Note that a lot of it will need to be ready before anything can be applied. ... I can see that this is all sensible stuff on Unix, but can you explain a bit more of what your Windows implementation is going to look like? The current file descriptor model with select() only admits the things which are associated with file descriptors on Windows, which means BSD sockets only (no eventfds or self-pipes to signal things to your event loop). If you want the send()/recv() calls to feed back into an I/O completion port for a Windows-style event loop then a lot more needs to change, because everything will have to be able to instead call WSASend()/WSARecv() with additional options. - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] Event loop
Mark Thompson (12021-02-17): > I can see that this is all sensible stuff on Unix, but can you explain > a bit more of what your Windows implementation is going to look like? I have no intention to write Windows code for this. Our current protocols use poll() internally, this event loop will do the same, and be exactly as portable as things are now. But it will be modular: if somebody later wants to write specific code for Windows, it will be possible and I will make sure it is as easy as possible. Does that sound acceptable? 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] [RFC] Event loop
Feb 17, 2021, 15:38 by geo...@nsup.org: > Lynne (12021-02-17): > >> I think I'd prefer an asynchronous library rather than libev. >> So libuv? >> > > I have on occasion straced node to debug things, and what I have > observed is: I don't want to touch it even with a very long stick. > > Wan you explain more precisely why you think libuv would be a better > choice than libev? > It's more actively developed by a large margin, and I generally prefer its API and how it works internally. If no one else prefers libuv I'm okay with libev. ___ 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] libsvtav1: Add logical_processors option
On 17/02/2021 18:58, Christopher Degawa wrote: On Sun, Feb 14, 2021 at 12:27 PM Christopher Degawa wrote: That said, if you have a general use-case where this is helpful and the documentation explains what it is doing (and warns about the bad cases) then maybe? The main use case we have internally is to able to run multiple instances of SvtAv1EncApp with `--lp 1` without worrying about potentially choking out all of them and also for testing for potential single versus multi-core issues. Also, it seems my wording was wrong and it's not to "certain CPUs", but to a "certain number of CPUs" Another usage for this option would be to limit the amount of memory used as right now the ram usage is tied to the numbers of cores used. So what does it actually do, then? I just tried running with it here and all of my threads get default affinity, so whatever it is actually doing it seems like it is nothing to do with logical processors. It changes the thread count slightly but still makes lots of threads. It does seem like the number correlates somehow with how much CPU it uses, but it's not an upper bound. - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] Event loop
On 17/02/2021 20:57, Nicolas George wrote: Mark Thompson (12021-02-17): I can see that this is all sensible stuff on Unix, but can you explain a bit more of what your Windows implementation is going to look like? I have no intention to write Windows code for this. Our current protocols use poll() internally, this event loop will do the same, and be exactly as portable as things are now. But it will be modular: if somebody later wants to write specific code for Windows, it will be possible and I will make sure it is as easy as possible. Does that sound acceptable? I'm not sure you can avoid writing Windows code for this to work at all, because I don't think poll() as we have now is sufficient to get the functionality you want. I also worry that codifying something in this form is going to exclude the possibility of getting a better result on Windows later, because that wouldn't involve file descriptors or internals calling default BSD send()/recv(). For example: On 01/02/2021 19:14, Nicolas George wrote: > The API would consist of just a few entry points: > > - allocate, init, free an AVScheduler; > - allocate, add, alter, remove, free events; > - start, run, stop the loop. How are you going to implement altering/removing an event or stopping the loop? On Unix you of course have an eventfd/self-pipe sitting in the poll() set on the event loop to interrupt it. On Windows you can't, because those things are not file descriptors. - Mark ___ 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] libavfilter: avoid UB nullptr-with-offset.
On Tue, Feb 16, 2021 at 03:53:08PM +, Jeremy Leconte wrote: > --- > libavfilter/vf_scale.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c > index 58eee96744..98cef5eb4b 100644 > --- a/libavfilter/vf_scale.c > +++ b/libavfilter/vf_scale.c > @@ -631,7 +631,7 @@ static int scale_slice(AVFilterLink *link, AVFrame > *out_buf, AVFrame *cur_pic, s > int in_stride[4],out_stride[4]; > int i; > > -for (i=0; i<4; i++) { > +for (i=0; i<4 && cur_pic->data[i] != NULL; i++) { > int vsub= ((i+1)&2) ? scale->vsub : 0; > in_stride[i] = cur_pic->linesize[i] * mul; > out_stride[i] = out_buf->linesize[i] * mul; This leaves parts of the array uninitialized Ill fix this (unless someone else does before me) thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v6 2/9] avcodec/vvc: add shared header for vvc
On 17/02/2021 01:51, Nuo Mi wrote: --- libavcodec/vvc.h | 142 +++ 1 file changed, 142 insertions(+) create mode 100644 libavcodec/vvc.h diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h new file mode 100644 index 00..ca15297d7a --- /dev/null +++ b/libavcodec/vvc.h @@ -0,0 +1,142 @@ +/* + * VVC shared code + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VVC_H +#define AVCODEC_VVC_H + +/** + * Table 5 – NAL unit type codes and NAL unit type classes + * in T-REC-H.266-202008 + */ +enum VVCNALUnitType { +VVC_TRAIL_NUT = 0, +VVC_STSA_NUT = 1, +VVC_RADL_NUT = 2, +VVC_RASL_NUT = 3, +VVC_RSV_VCL_4 = 4, +VVC_RSV_VCL_5 = 5, +VVC_RSV_VCL_6 = 6, +VVC_IDR_W_RADL = 7, +VVC_IDR_N_LP = 8, +VVC_CRA_NUT= 9, +VVC_GDR_NUT= 10, +VVC_RSV_IRAP_11= 11, +VVC_OPI_NUT= 12, +VVC_DCI_NUT= 13, +VVC_VPS_NUT= 14, +VVC_SPS_NUT= 15, +VVC_PPS_NUT= 16, +VVC_PREFIX_APS_NUT = 17, +VVC_SUFFIX_APS_NUT = 18, +VVC_PH_NUT = 19, +VVC_AUD_NUT= 20, +VVC_EOS_NUT= 21, +VVC_EOB_NUT= 22, +VVC_PREFIX_SEI_NUT = 23, +VVC_SUFFIX_SEI_NUT = 24, +VVC_FD_NUT = 25, +VVC_RSV_NVCL_26= 26, +VVC_RSV_NVCL_27= 27, +VVC_UNSPEC_28 = 28, +VVC_UNSPEC_29 = 29, +VVC_UNSPEC_30 = 30, +VVC_UNSPEC_31 = 31, +}; + +enum VVCSliceType { +VVC_SLICE_TYPE_B = 0, +VVC_SLICE_TYPE_P = 1, +VVC_SLICE_TYPE_I = 2, +}; + +enum { +//6.2 we can have 3 sample arrays +MAX_SAMPLE_ARRAYS = 3, Needs the "VVC_" prefix. + +//7.4.3.3 vps_max_layers_minus1 is u(6) +VVC_MAX_LAYERS = 64, + +//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 to 6, inclusive +VVC_MAX_SUBLAYERS = 7, + +//7.4.3.3 vps_num_ptls_minus1 is u(8) +VVC_MAX_PTLS = 256, + +//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8) +VVC_MAX_TOTAL_NUM_OLSS = 257, + +// 7.3.2.3: vps_video_parameter_set_id is u(4). +VVC_MAX_VPS_COUNT = 16, +// 7.3.2.4: sps_seq_parameter_set_id is u(4) +VVC_MAX_SPS_COUNT = 16, +// 7.3.2.5: pps_pic_parameter_set_id is u(6) +VVC_MAX_PPS_COUNT = 64, + +// 7.4.4.1: ptl_num_sub_profiles is u(8) +VVC_MAX_SUB_PROFILES = 256, + +// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * maxDpbPicBuf(8) +VVC_MAX_DPB_SIZE = 16, + +//7.4.3.4 sps_num_ref_pic_lists in range [0, 64] +VVC_MAX_REF_PIC_LISTS = 64, + +//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13] +VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13, + +//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − sps_qp_table_start_minus26[i]], +//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] −26 − QpBdOffset, 36] +//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in range [0, 74] +VVC_MAX_POINTS_IN_QP_TABLE = 75, + +// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31]. +VVC_MAX_CPB_CNT = 32, + +// A.4.1: the highest level allows a MaxLumaPs of 35 651 584. +VVC_MAX_LUMA_PS = 35651584, + +// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are +// constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/ +// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples. +VVC_MAX_WIDTH = 16888, +VVC_MAX_HEIGHT = 16888, + +// A.4.1: table A.1 allows at most 440 tiles per au for any level. +VVC_MAX_TILES_PER_AU = 440, +// A.4.1: table A.1 did not define max tile rows. +// in worest a case, we can have 1x440 tiles picture. +VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU, +// A.4.1: table A.1 allows at most 20 tile columns for any level. +VVC_MAX_TILE_COLUMNS = 20, + +// A.4.1 table A.1 allows at most 600 slice for any level. +VVC_MAX_SLICES = 600, + +// 7.4.8: in the worst case (tiles_enabled_flag and +// entropy_coding_sync_enabled_flag are both set), entry points can be +// placed at the beginning of every Ctb row in every tile, giving an +// upper bound of (num
Re: [FFmpeg-devel] [PATCH] libavfilter: avoid UB nullptr-with-offset.
Michael Niedermayer: > On Tue, Feb 16, 2021 at 03:53:08PM +, Jeremy Leconte wrote: >> --- >> libavfilter/vf_scale.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c >> index 58eee96744..98cef5eb4b 100644 >> --- a/libavfilter/vf_scale.c >> +++ b/libavfilter/vf_scale.c >> @@ -631,7 +631,7 @@ static int scale_slice(AVFilterLink *link, AVFrame >> *out_buf, AVFrame *cur_pic, s >> int in_stride[4],out_stride[4]; >> int i; >> >> -for (i=0; i<4; i++) { >> +for (i=0; i<4 && cur_pic->data[i] != NULL; i++) { >> int vsub= ((i+1)&2) ? scale->vsub : 0; >> in_stride[i] = cur_pic->linesize[i] * mul; >> out_stride[i] = out_buf->linesize[i] * mul; > > This leaves parts of the array uninitialized > Ill fix this (unless someone else does before me) > I noticed that GCC is smart enough to optimize a ptr = addend ? ptr + addend : addend to a simple ptr += addend (Clang isn't, but future version might do so). Maybe we should put the above in a macro and use it everywhere where such problems exist? (It would of course not fix the case of NULL + addend with addend != 0, but such cases are genuine logic bugs that should not be hidden, but fixed.) - 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 v6 3/9] avformat: add vvc raw demux
On 17/02/2021 01:51, Nuo Mi wrote: --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/vvcdec.c | 61 3 files changed, 63 insertions(+) create mode 100644 libavformat/vvcdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 10fee749c8..2b9d0eee7f 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -564,6 +564,7 @@ OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o OBJS-$(CONFIG_VPK_DEMUXER) += vpk.o OBJS-$(CONFIG_VPLAYER_DEMUXER) += vplayerdec.o subtitles.o OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o +OBJS-$(CONFIG_VVC_DEMUXER) += vvcdec.o rawdec.o OBJS-$(CONFIG_W64_DEMUXER) += wavdec.o w64.o pcm.o OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o OBJS-$(CONFIG_WAV_DEMUXER) += wavdec.o pcm.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index f837ddabc8..fb06723fb9 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -463,6 +463,7 @@ extern AVOutputFormat ff_voc_muxer; extern AVInputFormat ff_vpk_demuxer; extern AVInputFormat ff_vplayer_demuxer; extern AVInputFormat ff_vqf_demuxer; +extern AVInputFormat ff_vvc_demuxer; extern AVInputFormat ff_w64_demuxer; extern AVOutputFormat ff_w64_muxer; extern AVInputFormat ff_wav_demuxer; diff --git a/libavformat/vvcdec.c b/libavformat/vvcdec.c new file mode 100644 index 00..149f39f28e --- /dev/null +++ b/libavformat/vvcdec.c @@ -0,0 +1,61 @@ +/* + * RAW VVC video demuxer + * Copyright (c) 2020 Nuo Mi + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vvc.h" + +#include "avformat.h" +#include "rawdec.h" + +static int vvc_probe(const AVProbeData *p) +{ +uint32_t code = -1; +int sps = 0, pps = 0, irap = 0; +int i; + +for (i = 0; i < p->buf_size - 1; i++) { +code = (code << 8) + p->buf[i]; +if ((code & 0xff00) == 0x100) { +uint8_t nal2 = p->buf[i + 1]; +int type = (nal2 & 0xF8) >> 3; + +if (code & 0xc0) // forbidden_zero_bit and nuh_reserved_zero_bit +return 0; + +if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1 +return 0; + +switch (type) { +case VVC_SPS_NUT: sps++; break; +case VVC_PPS_NUT: pps++; break; +case VVC_IDR_N_LP: +case VVC_IDR_W_RADL: +case VVC_CRA_NUT: +case VVC_GDR_NUT: irap++; break; +} +} +} + +if (sps && pps && irap) +return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg How well does this test fully distinguish from previous standards using the same start code style? (Can I have an H.264 or H.265 raw stream which passes this test? Can an H.266 stream ever pass the test for those codecs, implying we need to update them?) +return 0; +} + +FF_DEF_RAWVIDEO_DEMUXER(vvc, "raw VVC video", vvc_probe, "h266,266,vvc", AV_CODEC_ID_VVC) - Mark ___ 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] avisynth: fix audio on big endian
--- Open for bikeshedding, as I'm not too sure of the names, but I didn't want to use anything too close to regular AV_CODEC_ID* defines. libavformat/avisynth.c | 21 + 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index f029a0e842..fbebb6707c 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -42,6 +42,19 @@ #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF #endif +/* Endianness guards for audio */ +#if HAVE_BIGENDIAN +#define AVISYNTH_PCM_OUT_S16 AV_CODEC_ID_PCM_S16BE +#define AVISYNTH_PCM_OUT_S24 AV_CODEC_ID_PCM_S24BE +#define AVISYNTH_PCM_OUT_S32 AV_CODEC_ID_PCM_S32BE +#define AVISYNTH_PCM_OUT_F32 AV_CODEC_ID_PCM_F32BE +#else +#define AVISYNTH_PCM_OUT_S16 AV_CODEC_ID_PCM_S16LE +#define AVISYNTH_PCM_OUT_S24 AV_CODEC_ID_PCM_S24LE +#define AVISYNTH_PCM_OUT_S32 AV_CODEC_ID_PCM_S32LE +#define AVISYNTH_PCM_OUT_F32 AV_CODEC_ID_PCM_F32LE +#endif + #include typedef struct AviSynthLibrary { @@ -496,16 +509,16 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st) st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; break; case AVS_SAMPLE_INT16: -st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; +st->codecpar->codec_id = AVISYNTH_PCM_OUT_S16; break; case AVS_SAMPLE_INT24: -st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; +st->codecpar->codec_id = AVISYNTH_PCM_OUT_S24; break; case AVS_SAMPLE_INT32: -st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; +st->codecpar->codec_id = AVISYNTH_PCM_OUT_S32; break; case AVS_SAMPLE_FLOAT: -st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; +st->codecpar->codec_id = AVISYNTH_PCM_OUT_F32; break; default: av_log(s, AV_LOG_ERROR, -- 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".
Re: [FFmpeg-devel] [PATCH] avfilter/vf_pseudocolor: Add missing braces
On 06/02/2021 22:04, Paul B Mahol wrote: Trivial, thus lgtm. Rebased and applied, apologies for the delay. Thanks, - Mark ___ 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] avisynth: fix audio on big endian
Stephen Hutchinson: > --- > Open for bikeshedding, as I'm not too sure of > the names, but I didn't want to use anything > too close to regular AV_CODEC_ID* defines. > libavformat/avisynth.c | 21 + > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c > index f029a0e842..fbebb6707c 100644 > --- a/libavformat/avisynth.c > +++ b/libavformat/avisynth.c > @@ -42,6 +42,19 @@ >#define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF > #endif > > +/* Endianness guards for audio */ > +#if HAVE_BIGENDIAN > +#define AVISYNTH_PCM_OUT_S16 AV_CODEC_ID_PCM_S16BE > +#define AVISYNTH_PCM_OUT_S24 AV_CODEC_ID_PCM_S24BE > +#define AVISYNTH_PCM_OUT_S32 AV_CODEC_ID_PCM_S32BE > +#define AVISYNTH_PCM_OUT_F32 AV_CODEC_ID_PCM_F32BE > +#else > +#define AVISYNTH_PCM_OUT_S16 AV_CODEC_ID_PCM_S16LE > +#define AVISYNTH_PCM_OUT_S24 AV_CODEC_ID_PCM_S24LE > +#define AVISYNTH_PCM_OUT_S32 AV_CODEC_ID_PCM_S32LE > +#define AVISYNTH_PCM_OUT_F32 AV_CODEC_ID_PCM_F32LE > +#endif #if HAVE_BIGENDION #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## BE) #else #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## LE) #endif With this the above lines would become st->codecpar->codec_id = PCM(S16) etc. Alternatively one could also use AV_NE directly. > + > #include > > typedef struct AviSynthLibrary { > @@ -496,16 +509,16 @@ static int avisynth_create_stream_audio(AVFormatContext > *s, AVStream *st) > st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; > break; > case AVS_SAMPLE_INT16: > -st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; > +st->codecpar->codec_id = AVISYNTH_PCM_OUT_S16; > break; > case AVS_SAMPLE_INT24: > -st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; > +st->codecpar->codec_id = AVISYNTH_PCM_OUT_S24; > break; > case AVS_SAMPLE_INT32: > -st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; > +st->codecpar->codec_id = AVISYNTH_PCM_OUT_S32; > break; > case AVS_SAMPLE_FLOAT: > -st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; > +st->codecpar->codec_id = AVISYNTH_PCM_OUT_F32; > break; > default: > av_log(s, AV_LOG_ERROR, > ___ 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] avisynth: fix audio on big endian
--- libavformat/avisynth.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index f029a0e842..4cd6d6bc90 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -42,6 +42,13 @@ #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF #endif +/* Endianness guards for audio */ +#if HAVE_BIGENDIAN +#define PCM(format) (AV_CODEC_ID_PCM_ ## format ## BE) +#else +#define PCM(format) (AV_CODEC_ID_PCM_ ## format ## LE) +#endif + #include typedef struct AviSynthLibrary { @@ -496,16 +503,16 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st) st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; break; case AVS_SAMPLE_INT16: -st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; +st->codecpar->codec_id = PCM(S16); break; case AVS_SAMPLE_INT24: -st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; +st->codecpar->codec_id = PCM(S24); break; case AVS_SAMPLE_INT32: -st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; +st->codecpar->codec_id = PCM(S32); break; case AVS_SAMPLE_FLOAT: -st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; +st->codecpar->codec_id = PCM(F32); break; default: av_log(s, AV_LOG_ERROR, -- 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".
Re: [FFmpeg-devel] [PATCH v6 4/9] avcodec: add cbs for h266/vvc
On 17/02/2021 01:51, Nuo Mi wrote: --- configure |2 + libavcodec/Makefile |1 + libavcodec/cbs.c |6 + libavcodec/cbs_h2645.c| 541 - libavcodec/cbs_h266.h | 817 +++ libavcodec/cbs_h266_syntax_template.c | 3006 + libavcodec/cbs_internal.h |3 +- libavcodec/cbs_sei.c | 29 + 8 files changed, 4397 insertions(+), 8 deletions(-) create mode 100644 libavcodec/cbs_h266.h create mode 100644 libavcodec/cbs_h266_syntax_template.c diff --git a/configure b/configure index a76c2ec4ae..11df59a229 100755 --- a/configure +++ b/configure @@ -2355,6 +2355,7 @@ CONFIG_EXTRA=" cbs_av1 cbs_h264 cbs_h265 +cbs_h266 cbs_jpeg cbs_mpeg2 cbs_vp9 @@ -2623,6 +2624,7 @@ threads_if_any="$THREADS_LIST" cbs_av1_select="cbs" cbs_h264_select="cbs" cbs_h265_select="cbs" +cbs_h266_select="cbs" cbs_jpeg_select="cbs" cbs_mpeg2_select="cbs" cbs_vp9_select="cbs" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3341801b97..23553e68e9 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -73,6 +73,7 @@ OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o +OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o h2645_parse.o OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index ecf22b3fdb..6baf21d62b 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -39,6 +39,9 @@ static const CodedBitstreamType *const cbs_type_table[] = { #if CONFIG_CBS_H265 &ff_cbs_type_h265, #endif +#if CONFIG_CBS_H266 +&ff_cbs_type_h266, +#endif #if CONFIG_CBS_JPEG &ff_cbs_type_jpeg, #endif @@ -60,6 +63,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = { #if CONFIG_CBS_H265 AV_CODEC_ID_H265, #endif +#if CONFIG_CBS_H266 +AV_CODEC_ID_H266, +#endif #if CONFIG_CBS_JPEG AV_CODEC_ID_MJPEG, #endif diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 57c419aa05..d39464ba49 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -24,12 +24,129 @@ #include "cbs_internal.h" #include "cbs_h264.h" #include "cbs_h265.h" +#include "cbs_h266.h" #include "h264.h" #include "h264_sei.h" #include "h2645_parse.h" #include "hevc.h" #include "hevc_sei.h" +#include "vvc.h" +#define H266_IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= VVC_GDR_NUT)) +#define H266_IS_IDR(nut) (nut == VVC_IDR_W_RADL || nut == VVC_IDR_N_LP) + +static void h266_au_detector_init(H266AuDetector* d) +{ +if (!d->inited) { +d->prev_layer_id = UINT8_MAX; +d->prev_poc = INT_MAX; +d->prev_tid0_poc = INT_MAX; +d->inited = 1; +} +} + +//8.3.1 Decoding process for picture order count. +//VTM did not follow the spec, and it's much simpler than spec. +//We follow the VTM. To clarify, does that mean that the VTM is wrong or that the spec defines it in an equivalent way which is overly complicated? +static int h266_get_slice_poc(CodedBitstreamH266Context *h266, void* log_ctx, + const H266RawPH *ph, const H266RawSliceHeader *slice, + int *poc) +{ +int poc_msb, max_poc_lsb, poc_lsb; +H266AuDetector* d = &h266->priv.au_detector; +const H266RawSPS* sps; +const H266RawPPS* pps; Please keep the '*'s as part of the declarator, not the declaration-specifiers (in lots of places in these functions). + +pps = h266->pps[ph->ph_pic_parameter_set_id]; +if (!pps) { +av_log(log_ctx, AV_LOG_ERROR, "PPS id %d is not avaliable.\n", + ph->ph_pic_parameter_set_id); +return AVERROR_INVALIDDATA; +} + +sps = h266->sps[pps->pps_seq_parameter_set_id]; +if (!sps) { +av_log(log_ctx, AV_LOG_ERROR, "SPS id %d is not avaliable.\n", + pps->pps_seq_parameter_set_id); +return AVERROR_INVALIDDATA; +} + +max_poc_lsb = 1 << (sps->sps_log2_max_pic_order_cnt_lsb_minus4 + 4); +poc_lsb = ph->ph_pic_order_cnt_lsb; +if (H266_IS_IDR(slice->nal_unit_header.nal_unit_type)) { +if (ph->ph_poc_msb_cycle_present_flag) +poc_msb = ph->ph_poc_msb_cycle_val * max_poc_lsb; +else +poc_msb = 0; +} else { +int prev_poc = d->prev_tid0_poc; +int prev_poc_lsb = prev_poc & (max_poc_lsb - 1); +int prev_poc_msb = prev_poc - prev_poc_lsb; +if (ph->ph_poc_msb_cycle_present_flag) { + poc_msb = ph->ph_poc_msb_cycle_val * max_poc
Re: [FFmpeg-devel] [PATCH v6 6/9] avcodec: add vvc parser
On 17/02/2021 01:51, Nuo Mi wrote: --- configure | 1 + libavcodec/Makefile | 1 + libavcodec/parsers.c| 1 + libavcodec/vvc_parser.c | 310 4 files changed, 313 insertions(+) create mode 100644 libavcodec/vvc_parser.c diff --git a/configure b/configure index 11df59a229..24463595d2 100755 --- a/configure +++ b/configure @@ -3167,6 +3167,7 @@ mpegaudio_parser_select="mpegaudioheader" mpegvideo_parser_select="mpegvideo" mpeg4video_parser_select="h263dsp mpegvideo qpeldsp" vc1_parser_select="vc1dsp" +vcc_parser_select="cbs_h266" Typo - "vcc". (There is no checking on names here, because they are just shell variables. The only way to verify if particular dependencies are correct is to build that thing with everything else disabled.) # bitstream_filters aac_adtstoasc_bsf_select="adts_header" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 23553e68e9..5adb96c8df 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1128,6 +1128,7 @@ OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \ OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o +OBJS-$(CONFIG_VVC_PARSER) += vvc_parser.o OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o OBJS-$(CONFIG_XBM_PARSER) += xbm_parser.o OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index f8cfa1cde9..61d753d680 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -72,6 +72,7 @@ extern AVCodecParser ff_vorbis_parser; extern AVCodecParser ff_vp3_parser; extern AVCodecParser ff_vp8_parser; extern AVCodecParser ff_vp9_parser; +extern AVCodecParser ff_vvc_parser; extern AVCodecParser ff_webp_parser; extern AVCodecParser ff_xbm_parser; extern AVCodecParser ff_xma_parser; diff --git a/libavcodec/vvc_parser.c b/libavcodec/vvc_parser.c new file mode 100644 index 00..4b4aa4b625 --- /dev/null +++ b/libavcodec/vvc_parser.c @@ -0,0 +1,310 @@ +/* + * VVC parser + * + * Copyright (C) 2029 Nuo Mi Code from the future! + * ... - Mark ___ 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] avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config parameters
Getting rid of unnecessary use of AVDictionary object in parsing vpx_svc_ref_frame_config. --- libavcodec/libvpxenc.c | 76 -- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 284cb9a108..abfd0032c1 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -42,6 +42,7 @@ #include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/avstring.h" /** * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. @@ -127,7 +128,6 @@ typedef struct VPxEncoderContext { int roi_warned; #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) vpx_svc_ref_frame_config_t ref_frame_config; -AVDictionary *vpx_ref_frame_config; #endif } VPxContext; @@ -561,18 +561,13 @@ static int vpx_ts_param_parse(VPxContext *ctx, struct vpx_codec_enc_cfg *enccfg, } #if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT) -static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct vpx_codec_enc_cfg *enccfg, - char *key, char *value, enum AVCodecID codec_id) +static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t *ref_frame_config, + int ss_number_layers, char *key, char *value) { size_t value_len = strlen(value); -int ss_number_layers = enccfg->ss_number_layers; -vpx_svc_ref_frame_config_t *ref_frame_config = &ctx->ref_frame_config; if (!value_len) -return -1; - -if (codec_id != AV_CODEC_ID_VP9) -return -1; +return AVERROR(EINVAL); if (!strcmp(key, "rfc_update_buffer_slot")) { vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot, value, value_len, ss_number_layers); @@ -600,6 +595,52 @@ static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct vpx_codec_en return 0; } + +static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t *ref_frame_config, int ss_number_layers, + const char **buf, const char *key_val_sep, const char *pairs_sep) +{ +char *key = av_get_token(buf, key_val_sep); +char *val = NULL; +int ret; + +if (key && *key && strspn(*buf, key_val_sep)) { +(*buf)++; +val = av_get_token(buf, pairs_sep); +} + +if (key && *key && val && *val) +ret = vpx_ref_frame_config_set_value(ref_frame_config, ss_number_layers, key, val); +else +ret = AVERROR(EINVAL); + +av_freep(&key); +av_freep(&val); + +return ret; +} + +static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t *ref_frame_config, int ss_number_layers, + const char *str, const char *key_val_sep, const char *pairs_sep) +{ +int ret = 0; + +if (!ref_frame_config) +return AVERROR(EINVAL); + +if (!str) +return AVERROR(EINVAL); + +while (*str) { +if ((ret = vpx_parse_ref_frame_config_element(ref_frame_config, ss_number_layers, + &str, key_val_sep, pairs_sep)) !=0) +return ret; + +if (*str) +str++; +} + +return ret; +} #endif #if CONFIG_LIBVPX_VP9_ENCODER @@ -1594,20 +1635,19 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, if (en) { if (avctx->codec_id == AV_CODEC_ID_VP9) { -AVDictionaryEntry* en2 = NULL; -av_dict_parse_string(&ctx->vpx_ref_frame_config, en->value, "=", ":", 0); - -while ((en2 = av_dict_get(ctx->vpx_ref_frame_config, "", en2, AV_DICT_IGNORE_SUFFIX))) { -if (vpx_ref_frame_config_parse(ctx, enccfg, en2->key, en2->value, avctx->codec_id) < 0) -av_log(avctx, AV_LOG_WARNING, - "Error parsing option '%s = %s'.\n", - en2->key, en2->value); +int ret; +ret = vpx_parse_ref_frame_config(&ctx->ref_frame_config, + enccfg->ss_number_layers, en->value, "=", ":"); +if (ret != 0) { +av_log(avctx, AV_LOG_WARNING, + "Error parsing ref_frame_config option %s.\n", en->value); +return ret; } codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (int *)&ctx->ref_frame_config); } else { av_log(avctx, AV_LOG_WARNING, - "Error using option ref-frame-config for a non-VP9 codec\n"); + "Using option ref-frame-config for a non-VP9 codec\n"); } } #endif -- 2.30.0.4
Re: [FFmpeg-devel] [PATCH] libsvtav1: Add logical_processors option
> > It does seem like the number correlates somehow with how much CPU it > uses, but it's not an upper bound. > If it isn't, then that might be an issue, but the idea is that with the logical_processor option you can limit the amount of ram a single encoder instance will use since on a system with a lot of cores, but not much ram, the encoder will error out when it tries to allocate more than what is available. I can probably add that to the doc as the potential use case. https://gitlab.com/AOMediaCodec/SVT-AV1#hardware ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 01/29] configure, libavcodec/Makefile: Remove spurious CAF demuxer dependencies
Forgotten in 604fbb3132e88727e496c96c92cfe02748c25a1a. Signed-off-by: Andreas Rheinhardt --- configure | 2 +- libavcodec/Makefile | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/configure b/configure index a76c2ec4ae..c28a7403db 100755 --- a/configure +++ b/configure @@ -3308,7 +3308,7 @@ asf_stream_muxer_select="asf_muxer" av1_demuxer_select="av1_frame_merge_bsf av1_parser" avi_demuxer_select="iso_media riffdec exif" avi_muxer_select="riffenc" -caf_demuxer_select="iso_media riffdec" +caf_demuxer_select="iso_media" caf_muxer_select="iso_media" dash_muxer_select="mp4_muxer" dash_demuxer_deps="libxml2" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3341801b97..f43e717714 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -974,7 +974,6 @@ OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec.o OBJS-$(CONFIG_ISO_MEDIA) += mpeg4audio.o mpegaudiodata.o OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o -OBJS-$(CONFIG_CAF_DEMUXER) += ac3tab.o OBJS-$(CONFIG_CODEC2_DEMUXER) += codec2utils.o OBJS-$(CONFIG_CODEC2_MUXER)+= codec2utils.o OBJS-$(CONFIG_CODEC2RAW_DEMUXER) += codec2utils.o -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 02/29] avcodec/Makefile: Remove spurios dcaenc dependency
It does not need dca.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f43e717714..92a3dcf0fc 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -276,7 +276,7 @@ OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ dca_core.o dca_exss.o dca_xll.o dca_lbr.o \ dcadsp.o dcadct.o synth_filter.o -OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o dcahuff.o \ +OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dcadata.o dcahuff.o \ dcaadpcm.o OBJS-$(CONFIG_DDS_DECODER) += dds.o OBJS-$(CONFIG_DERF_DPCM_DECODER) += dpcm.o -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 03/29] avcodec/avrndec: Remove unnecessary headers
The avrn decoder does not use any internals of the MJPEG decoder since e0031ca29a471c4a540ba2e01b3f81af03ef757b. Signed-off-by: Andreas Rheinhardt --- libavcodec/avrndec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index d85e3c2000..9380d86885 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -21,8 +21,6 @@ #include "avcodec.h" #include "internal.h" -#include "mjpeg.h" -#include "mjpegdec.h" #include "libavutil/imgutils.h" typedef struct { -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 10/29] configure: Remove mpegvideo_enc dependency from ljpeg encoder
It only existed because some code in mjpegenc_common.c relied on it; yet said code was actually only used by mjpegenc.c and has been moved there. Signed-off-by: Andreas Rheinhardt --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 21139b9170..e918c4e670 100755 --- a/configure +++ b/configure @@ -2761,7 +2761,7 @@ interplay_video_decoder_select="hpeldsp" jpegls_decoder_select="mjpeg_decoder" jv_decoder_select="blockdsp" lagarith_decoder_select="llviddsp" -ljpeg_encoder_select="idctdsp jpegtables mpegvideoenc" +ljpeg_encoder_select="idctdsp jpegtables" lscr_decoder_deps="zlib" magicyuv_decoder_select="llviddsp" magicyuv_encoder_select="llvidencdsp" -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/29] configure, libavcodec/Makefile: Fix avrn dependencies
The avrn decoder actually only needs one thing: The MJPEG decoder. Instead the Makefile made it compile mjpegdec and configure required some of the prerequisites of the MJPEG decoder (exif and jpegtables). Even if all the prerequisites of the MJPEG decoder were required, it would still not make the MJPEG decoder usable, because for that the MJPEG decoder needs to be in the list of codecs in codec_list.c. Signed-off-by: Andreas Rheinhardt --- The avrn decoder like several other decoders uses avcodec_find_decoder to get the MJPEG decoder; is there actually a reason not to just use avcodec_alloc_context3(&ff_mjpeg_decoder)? configure | 2 +- libavcodec/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index c28a7403db..21139b9170 100755 --- a/configure +++ b/configure @@ -2688,7 +2688,7 @@ atrac3p_decoder_select="mdct sinewin" atrac3pal_decoder_select="mdct sinewin" atrac9_decoder_select="mdct" av1_decoder_select="cbs_av1" -avrn_decoder_select="exif jpegtables" +avrn_decoder_select="mjpeg_decoder" bink_decoder_select="blockdsp hpeldsp" binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs" binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 92a3dcf0fc..4125355e37 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -231,7 +231,7 @@ OBJS-$(CONFIG_AURA_DECODER)+= cyuv.o OBJS-$(CONFIG_AURA2_DECODER) += aura.o OBJS-$(CONFIG_AV1_DECODER) += av1dec.o OBJS-$(CONFIG_AV1_CUVID_DECODER) += cuviddec.o -OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o mjpegdec.o +OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o OBJS-$(CONFIG_AVRP_ENCODER)+= r210enc.o OBJS-$(CONFIG_AVS_DECODER) += avs.o -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/29] avcodec/Makefile: Remove redundant mjpegdec dependency from tiff decoder
The MJPEG decoder is already activated by configure whenever the tiff decoder is selected; ergo it is unnecessary to add a dependency in the Makefile. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4125355e37..332a9bc766 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -657,7 +657,7 @@ OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o rle.o OBJS-$(CONFIG_TARGA_Y216_DECODER) += targa_y216dec.o OBJS-$(CONFIG_TDSC_DECODER)+= tdsc.o OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o -OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o tiff_common.o mjpegdec.o +OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o tiff_common.o OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o tiff_data.o OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o OBJS-$(CONFIG_TRUEHD_DECODER) += mlpdec.o mlpdsp.o -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 11/29] avcodec/scpr3: Avoid code duplication when updating models
Signed-off-by: Andreas Rheinhardt --- libavcodec/scpr3.c | 24 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c index 1ed764baa1..78c58889cb 100644 --- a/libavcodec/scpr3.c +++ b/libavcodec/scpr3.c @@ -524,32 +524,16 @@ static int update_model1_to_4(PixelModel3 *m, uint32_t val) static int update_model1_to_5(PixelModel3 *m, uint32_t val) { -PixelModel3 n = {0}; int i, size, freqs; uint32_t a; +update_model1_to_4(m, val); size = m->size; -n.size = size; -for (i = 0; i < size; i++) { -n.symbols[i] = m->symbols[i]; -} -AV_QSORT(n.symbols, size, uint8_t, cmpbytes); -size = n.size; -for (i = 0; i < size; i++) { -if (val == n.symbols[i]) { -n.freqs[i] = 100; -n.maxpos = i; -} else { -n.freqs[i] = 50; -} -} a = 256 - size; for (i = 0; i < size; i++, a += freqs) -freqs = n.freqs[i]; -n.type = 5; -n.cntsum = a; - -memcpy(m, &n, sizeof(n)); +freqs = m->freqs[i]; +m->type = 5; +m->cntsum = a; return 0; } -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 06/29] avcodec/g2meet, mjpegdec: Factor out common VLC initialization code
While just at it, remove the nb_codes parameter: It is redundant (the number of codes is implicitly contained in the array containing how many entries of a specific size there are) and for this reason it might even be wrong, so it is better to check what is actually used instead. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 4 +-- libavcodec/g2meet.c | 38 ++-- libavcodec/mjpegdec.c| 48 +- libavcodec/mjpegdec.h| 2 ++ libavcodec/mjpegdec_common.c | 57 5 files changed, 77 insertions(+), 72 deletions(-) create mode 100644 libavcodec/mjpegdec_common.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 332a9bc766..c427de78be 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -341,7 +341,7 @@ OBJS-$(CONFIG_FMVC_DECODER)+= fmvc.o OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o OBJS-$(CONFIG_FRWU_DECODER)+= frwu.o -OBJS-$(CONFIG_G2M_DECODER) += g2meet.o elsdec.o +OBJS-$(CONFIG_G2M_DECODER) += g2meet.o elsdec.o mjpegdec_common.o OBJS-$(CONFIG_G723_1_DECODER) += g723_1dec.o g723_1.o \ acelp_vectors.o celp_filters.o celp_math.o OBJS-$(CONFIG_G723_1_ENCODER) += g723_1enc.o g723_1.o \ @@ -450,7 +450,7 @@ OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \ twinvq.o OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o -OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o +OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o mjpegdec_common.o OBJS-$(CONFIG_MJPEG_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o \ mjpegenc_huffman.o diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index 70dc8c72a3..68b1b9dc74 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -41,6 +41,7 @@ #include "internal.h" #include "jpegtables.h" #include "mjpeg.h" +#include "mjpegdec.h" #define EPIC_PIX_STACK_SIZE 1024 #define EPIC_PIX_STACK_MAX (EPIC_PIX_STACK_SIZE - 1) @@ -159,45 +160,24 @@ typedef struct G2MContext { intcursor_hot_x, cursor_hot_y; } G2MContext; -static av_cold int build_vlc(VLC *vlc, const uint8_t *bits_table, - const uint8_t *val_table, int nb_codes, - int is_ac) -{ -uint8_t huff_size[256] = { 0 }; -uint16_t huff_code[256]; -uint16_t huff_sym[256]; -int i; - -ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table); - -for (i = 0; i < 256; i++) -huff_sym[i] = i + 16 * is_ac; - -if (is_ac) -huff_sym[0] = 16 * 256; - -return ff_init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1, - huff_code, 2, 2, huff_sym, 2, 2, 0); -} - static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c) { int ret; -ret = build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance, -avpriv_mjpeg_val_dc, 12, 0); +ret = ff_mjpeg_build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance, + avpriv_mjpeg_val_dc, 0, avctx); if (ret) return ret; -ret = build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance, -avpriv_mjpeg_val_dc, 12, 0); +ret = ff_mjpeg_build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance, + avpriv_mjpeg_val_dc, 0, avctx); if (ret) return ret; -ret = build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance, -avpriv_mjpeg_val_ac_luminance, 251, 1); +ret = ff_mjpeg_build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance, + avpriv_mjpeg_val_ac_luminance, 1, avctx); if (ret) return ret; -ret = build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance, -avpriv_mjpeg_val_ac_chrominance, 251, 1); +ret = ff_mjpeg_build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance, + avpriv_mjpeg_val_ac_chrominance, 1, avctx); if (ret) return ret; diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index fa4c607085..f35bbeedee 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -51,40 +51,6 @@ #include "bytestream.h" -static void build_huffman_codes(uint8_t *huff_size, const uint8_t *bits_table) -{ -for (int i = 1, k = 0; i <= 16; i++) { -int nb = bits_table[i]; -for (int j = 0; j < nb;j++) { -huff_size[k] = i; -k++; -} -} -} - -static int build_vlc(VLC *vlc, const uint8_t *bits_table, - const uint8_t *val_table, int nb_codes, -
[FFmpeg-devel] [PATCH 13/29] avcodec/Makefile: Remove outdated dependency of FLV demuxer on mpeg4audio
Unneeded since f96a653184e63cea91e08ea75ae60d309e431f40 and b2bb09bcc330156e9d79d7ddfa59f9c5d05ca149. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 8a835a26ab..24725d8666 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -978,7 +978,6 @@ OBJS-$(CONFIG_CODEC2_MUXER)+= codec2utils.o OBJS-$(CONFIG_CODEC2RAW_DEMUXER) += codec2utils.o OBJS-$(CONFIG_DNXHD_DEMUXER) += dnxhddata.o OBJS-$(CONFIG_FITS_DEMUXER)+= fits.o -OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)+= mpeg4audio.o OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 12/29] avcodec/mpeg4audio: Use proper logcontext for logging
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg4audio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index 77cf2fb61c..2286303b54 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -30,7 +30,7 @@ * @param[in] cMPEG4AudioConfig structure to fill * @return on success 0 is returned, otherwise a value < 0 */ -static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c) +static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c, void *logctx) { if (get_bits_left(gb) < 112) return AVERROR_INVALIDDATA; @@ -43,7 +43,7 @@ static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c) c->sample_rate = get_bits_long(gb, 32); if (c->sample_rate <= 0) { -av_log(NULL, AV_LOG_ERROR, "Invalid sample rate %d\n", c->sample_rate); +av_log(logctx, AV_LOG_ERROR, "Invalid sample rate %d\n", c->sample_rate); return AVERROR_INVALIDDATA; } @@ -136,7 +136,7 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb, specific_config_bitindex = get_bits_count(gb); -ret = parse_config_ALS(gb, c); +ret = parse_config_ALS(gb, c, logctx); if (ret < 0) return ret; } -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/29] avcodec/jpegtables: Move ff_mjpeg_build_huffman_codes to mjpegenc_common
Since g2meet.c doesn't use it any more, only encoders use it and the place for their common code is mjpegenc_common.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/jpegtables.c | 21 - libavcodec/jpegtables.h | 4 libavcodec/mjpegenc_common.c | 21 + libavcodec/mjpegenc_common.h | 3 +++ 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c index e44bc7a22a..ef3f8dee20 100644 --- a/libavcodec/jpegtables.c +++ b/libavcodec/jpegtables.c @@ -122,24 +122,3 @@ const uint8_t avpriv_mjpeg_val_ac_chrominance[] = 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa }; - -/* isn't this function nicer than the one in the libjpeg ? */ -void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, - const uint8_t *bits_table, - const uint8_t *val_table) -{ -int i, j, k,nb, code, sym; - -k = 0; -code = 0; -for(i=1;i<=16;i++) { -nb = bits_table[i]; -for(j=0;jhttps://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/29] avformat/Makefile: Remove outdated AIFF demuxer dependency on iso_media
This is a result of the mov channel parsing stuff being factored out of mov.c twice: Once in 91b782720fd0df5571775b6591bc41797d6ecf78 to isom.c and later in 3bab7cd12802dc5abf2c5cc6dec49e9e249ce204. Also remove the isom.h header; and while just at it, remove an unused mathematics.h inclusion. (isom.c actually depends upon mpeg4audio from libavcodec for avpriv_mpeg4audio_get_config2 and avpriv_mpa_freq_tab; yet there is no configure dependency for iso_media which leads to failure of shared builds.) Signed-off-by: Andreas Rheinhardt --- libavformat/Makefile | 2 +- libavformat/aiffdec.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 10fee749c8..851d2f13ee 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -81,7 +81,7 @@ OBJS-$(CONFIG_ADX_DEMUXER) += adxdec.o OBJS-$(CONFIG_ADX_MUXER) += rawenc.o OBJS-$(CONFIG_AEA_DEMUXER) += aea.o pcm.o OBJS-$(CONFIG_AFC_DEMUXER) += afc.o -OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o pcm.o isom.o \ +OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o pcm.o \ mov_chan.o replaygain.o OBJS-$(CONFIG_AIFF_MUXER)+= aiffenc.o id3v2enc.o OBJS-$(CONFIG_AIX_DEMUXER) += aixdec.o diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 4d1c9bbb53..81189316ff 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -20,13 +20,11 @@ */ #include "libavutil/intreadwrite.h" -#include "libavutil/mathematics.h" #include "libavutil/dict.h" #include "avformat.h" #include "internal.h" #include "pcm.h" #include "aiff.h" -#include "isom.h" #include "id3v2.h" #include "mov_chan.h" #include "replaygain.h" -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 08/29] avcodec/mjpegenc_common: Move stuff only used by mjpegenc.c to it
This allows to make ff_init_uni_ac_vlc static; ff_mjpeg_encode_picture_frame has also been made static, but it could always have been made static. Signed-off-by: Andreas Rheinhardt --- libavcodec/ljpegenc.c| 2 + libavcodec/mjpegenc.c| 191 +- libavcodec/mjpegenc.h| 1 + libavcodec/mjpegenc_common.c | 194 --- libavcodec/mjpegenc_common.h | 5 - 5 files changed, 192 insertions(+), 201 deletions(-) diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 39ce5a0089..3c68c08a3c 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -32,12 +32,14 @@ #include "libavutil/frame.h" #include "libavutil/mem.h" +#include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" #include "idctdsp.h" #include "internal.h" #include "jpegtables.h" +#include "mathops.h" #include "mjpegenc_common.h" #include "mjpeg.h" diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 466f48eba9..22af094da7 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -35,11 +35,198 @@ #include "avcodec.h" #include "jpegtables.h" #include "mjpegenc_common.h" +#include "mjpegenc_huffman.h" #include "mpegvideo.h" #include "mjpeg.h" #include "mjpegenc.h" #include "profiles.h" +static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256], +uint8_t *uni_ac_vlc_len) +{ +for (int i = 0; i < 128; i++) { +int level = i - 64; +if (!level) +continue; +for (int run = 0; run < 64; run++) { +int len, code, nbits; +int alevel = FFABS(level); + +len = (run >> 4) * huff_size_ac[0xf0]; + +nbits= av_log2_16bit(alevel) + 1; +code = ((15&run) << 4) | nbits; + +len += huff_size_ac[code] + nbits; + +uni_ac_vlc_len[UNI_AC_ENC_INDEX(run, i)] = len; +// We ignore EOB as its just a constant which does not change generally +} +} +} + +/** + * Encodes and outputs the entire frame in the JPEG format. + * + * @param s The MpegEncContext. + */ +static void mjpeg_encode_picture_frame(MpegEncContext *s) +{ +int nbits, code, table_id; +MJpegContext *m = s->mjpeg_ctx; +uint8_t *huff_size[4] = { m->huff_size_dc_luminance, + m->huff_size_dc_chrominance, + m->huff_size_ac_luminance, + m->huff_size_ac_chrominance }; +uint16_t *huff_code[4] = { m->huff_code_dc_luminance, + m->huff_code_dc_chrominance, + m->huff_code_ac_luminance, + m->huff_code_ac_chrominance }; +size_t total_bits = 0; +size_t bytes_needed; + +s->header_bits = get_bits_diff(s); +// Estimate the total size first +for (int i = 0; i < m->huff_ncode; i++) { +table_id = m->huff_buffer[i].table_id; +code = m->huff_buffer[i].code; +nbits = code & 0xf; + +total_bits += huff_size[table_id][code] + nbits; +} + +bytes_needed = (total_bits + 7) / 8; +ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed); + +for (int i = 0; i < m->huff_ncode; i++) { +table_id = m->huff_buffer[i].table_id; +code = m->huff_buffer[i].code; +nbits = code & 0xf; + +put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]); +if (nbits != 0) { +put_sbits(&s->pb, nbits, m->huff_buffer[i].mant); +} +} + +m->huff_ncode = 0; +s->i_tex_bits = get_bits_diff(s); +} + +/** + * Builds all 4 optimal Huffman tables. + * + * Uses the data stored in the JPEG buffer to compute the tables. + * Stores the Huffman tables in the bits_* and val_* arrays in the MJpegContext. + * + * @param m MJpegContext containing the JPEG buffer. + */ +static void mjpeg_build_optimal_huffman(MJpegContext *m) +{ +MJpegEncHuffmanContext dc_luminance_ctx; +MJpegEncHuffmanContext dc_chrominance_ctx; +MJpegEncHuffmanContext ac_luminance_ctx; +MJpegEncHuffmanContext ac_chrominance_ctx; +MJpegEncHuffmanContext *ctx[4] = { &dc_luminance_ctx, + &dc_chrominance_ctx, + &ac_luminance_ctx, + &ac_chrominance_ctx }; +for (int i = 0; i < 4; i++) +ff_mjpeg_encode_huffman_init(ctx[i]); + +for (int i = 0; i < m->huff_ncode; i++) { +int table_id = m->huff_buffer[i].table_id; +int code = m->huff_buffer[i].code; + +ff_mjpeg_encode_huffman_increment(ctx[table_id], code); +} + +ff_mjpeg_encode_huffman_close(&dc_luminance_ctx, + m->bits_dc_luminance, + m->val_dc_luminance, 12); +ff_mjpeg_encode_huffman_close(&dc_chrominance_ctx, +
[FFmpeg-devel] [PATCH 09/29] avcodec/Makefile: Don't build mjpegenc_huffman unconditionally
Only the mjpeg and amv encoders as well as its testprogram actually need it. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c427de78be..8a835a26ab 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -48,7 +48,6 @@ OBJS = ac3_parser.o \ mediacodec.o \ mpeg12framerate.o\ options.o\ - mjpegenc_huffman.o \ parser.o \ parsers.o\ profiles.o \ @@ -1218,7 +1217,6 @@ TESTPROGS = avpacket \ jpeg2000dwt \ mathops\ options \ -mjpegenc_huffman\ utils \ TESTPROGS-$(CONFIG_CABAC) += cabac @@ -1227,6 +1225,7 @@ TESTPROGS-$(CONFIG_FFT) += fft fft-fixed32 TESTPROGS-$(CONFIG_GOLOMB)+= golomb TESTPROGS-$(CONFIG_IDCTDSP) += dct TESTPROGS-$(CONFIG_IIRFILTER) += iirfilter +TESTPROGS-$(CONFIG_MJPEG_ENCODER) += mjpegenc_huffman TESTPROGS-$(HAVE_MMX) += motion TESTPROGS-$(CONFIG_MPEGVIDEO) += mpeg12framerate TESTPROGS-$(CONFIG_H264_METADATA_BSF) += h264_levels -- 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 16/29] avformat/isom: Remove outcommented function
There is another ff_mov_read_chan in mov_chan.c. Signed-off-by: Andreas Rheinhardt --- libavformat/isom.c | 39 --- 1 file changed, 39 deletions(-) diff --git a/libavformat/isom.c b/libavformat/isom.c index e0e50f71b1..df98779149 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -418,45 +418,6 @@ static const MovChannelLayout mov_channel_layout[] = { { AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY, (137<<16) | 5}, // kCAFChannelLayoutTag_DVD_11 { 0, 0}, }; -#if 0 -int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size) -{ -AVCodecContext *codec= st->codec; -uint32_t layout_tag; -AVIOContext *pb = s->pb; -const MovChannelLayout *layouts = mov_channel_layout; - -if (size < 12) -return AVERROR_INVALIDDATA; - -layout_tag = avio_rb32(pb); -size -= 4; -if (layout_tag == 0) { // kCAFChannelLayoutTag_UseChannelDescriptions -// Channel descriptions not implemented -av_log_ask_for_sample(s, "Unimplemented container channel layout.\n"); -avio_skip(pb, size); -return 0; -} -if (layout_tag == 0x1) { // kCAFChannelLayoutTag_UseChannelBitmap -codec->channel_layout = avio_rb32(pb); -size -= 4; -avio_skip(pb, size); -return 0; -} -while (layouts->channel_layout) { -if (layout_tag == layouts->layout_tag) { -codec->channel_layout = layouts->channel_layout; -break; -} -layouts++; -} -if (!codec->channel_layout) -av_log(s, AV_LOG_WARNING, "Unknown container channel layout.\n"); -avio_skip(pb, size); - -return 0; -} -#endif void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout) { -- 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 17/29] avformat/au: Deduplicate codec_tag lists
Also saves a relocation. Signed-off-by: Andreas Rheinhardt --- libavformat/au.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/au.c b/libavformat/au.c index 4f2b81119f..c2c1b7a3a3 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -53,6 +53,8 @@ static const AVCodecTag codec_au_tags[] = { { AV_CODEC_ID_NONE, 0 }, }; +static const AVCodecTag *const au_codec_tags[] = { codec_au_tags, NULL }; + #if CONFIG_AU_DEMUXER static int au_probe(const AVProbeData *p) @@ -231,7 +233,7 @@ AVInputFormat ff_au_demuxer = { .read_header = au_read_header, .read_packet = ff_pcm_read_packet, .read_seek = ff_pcm_read_seek, -.codec_tag = (const AVCodecTag* const []) { codec_au_tags, 0 }, +.codec_tag = au_codec_tags, }; #endif /* CONFIG_AU_DEMUXER */ @@ -337,7 +339,7 @@ AVOutputFormat ff_au_muxer = { .write_header = au_write_header, .write_packet = ff_raw_write_packet, .write_trailer = au_write_trailer, -.codec_tag = (const AVCodecTag* const []) { codec_au_tags, 0 }, +.codec_tag = au_codec_tags, .flags = AVFMT_NOTIMESTAMPS, }; -- 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 18/29] avformat/asfenc: Deduplicate codec tags lists
Also saves relocations. Signed-off-by: Andreas Rheinhardt --- libavformat/asfenc.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 8b24264c94..23a09efe05 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -258,6 +258,10 @@ static const AVCodecTag codec_asf_bmp_tags[] = { { AV_CODEC_ID_NONE, 0 }, }; +static const AVCodecTag *const asf_codec_tags[] = { +codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, NULL +}; + #define PREROLL_TIME 3100 static void put_str16(AVIOContext *s, const char *tag) @@ -1170,9 +1174,7 @@ AVOutputFormat ff_asf_muxer = { .write_packet = asf_write_packet, .write_trailer = asf_write_trailer, .flags = AVFMT_GLOBALHEADER, -.codec_tag = (const AVCodecTag * const []) { -codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0 -}, +.codec_tag = asf_codec_tags, .priv_class= &asf_muxer_class, }; #endif /* CONFIG_ASF_MUXER */ @@ -1197,9 +1199,7 @@ AVOutputFormat ff_asf_stream_muxer = { .write_packet = asf_write_packet, .write_trailer = asf_write_trailer, .flags = AVFMT_GLOBALHEADER, -.codec_tag = (const AVCodecTag * const []) { -codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0 -}, +.codec_tag = asf_codec_tags, .priv_class= &asf_stream_muxer_class, }; #endif /* CONFIG_ASF_STREAM_MUXER */ -- 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".