Re: [FFmpeg-devel] [PATCH] avfilter: Added siti filter
Am 22.03.22 um 09:36 schrieb Thilo Borgmann: Am 18.03.22 um 15:04 schrieb Paul B Mahol: On 3/18/22, Thilo Borgmann wrote: On 12 Mar 2022, at 10:06, Thilo Borgmann wrote: Am 09.03.22 um 18:31 schrieb Paul B Mahol: On 3/8/22, Thilo Borgmann wrote: Am 07.03.22 um 20:06 schrieb Paul B Mahol: On 3/7/22, Thilo Borgmann wrote: Am 06.03.22 um 22:25 schrieb Paul B Mahol: On 3/6/22, Thilo Borgmann wrote: Am 22.02.22 um 12:30 schrieb Thilo Borgmann: Am 18.02.22 um 17:08 schrieb Paul B Mahol: On Sat, Feb 12, 2022 at 11:55 AM Thilo Borgmann wrote: Am 31.01.22 um 12:55 schrieb James Almer: On 1/31/2022 8:53 AM, Anton Khirnov wrote: Quoting Thilo Borgmann (2022-01-18 14:58:07) Violations of code style. Enhanced. Not enough. There are still many remaining, e.g. * opening brace of a function definition should be on its own line * the context should generally be the first argument * unsigned char* should be uint8_t* * mixed declarations and code (the compiler should warn about that) I think someone said that clang (or some versions) is apparently not warning about this, hence why so many of these end up being missed in reviews or even by the patch author. This and all of Anton's comments in v3. Also removed some more obviously useless doubles. Why it uses doubles in so many places? Is there any real benefit in that, except extra slowdown? I guess because it's originating in some c&p Matlab code. I did %s#double#float#g for v4, loosing some precision we can ignore IMHO. v3: Total frames: 2 Spatial Information: Average: 165.451985 Max: 165.817542 Min: 165.086427 Temporal Information: Average: 1.007263 Max: 2.014525 Min: 0.00 v4: Total frames: 2 Spatial Information: Average: 164.385895 Max: 164.742325 Min: 164.029480 Temporal Information: Average: 1.007241 Max: 2.014483 Min: 0.00 Ping. Into wrong section of changelog added entry. Useless cast of allocation results. Does filter changes pixels? If not, add metadata flag to appropriate place. All addressed in v5, thx! Changelog entry is still in wrong, 5.0, section. Fixed in v6. Also added a FATE test for it. Could use fminf/ float functions instead of double variants. v7. Going to push soon if there are no more comments. Check that returned values are correct for bigger w/h, and that not values reach too high values for floats which may cause loss of precision in best case, eg. maybe you need to normalize pixel values from 0-255 to 0.f-1.f so mean/stddev does not get bad results. Did the accumulators as doubles then, good? Also found another missing fmaxf(). V8 attached. Ping. -Thilo ___ 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/apedec: fix a integer overflow in long_filter_high_3800()
Fixes: signed integer overflow: -2146549696 - 3923884 cannot be represented in type 'int' Fixes: 45907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5992380584558592 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/apedec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index f7f8a88994..65e5d152e0 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -959,7 +959,7 @@ static void long_filter_high_3800(int32_t *buffer, int order, int shift, int len dotprod += delay[j] * (unsigned)coeffs[j]; coeffs[j] += ((delay[j] >> 31) | 1) * sign; } -buffer[i] -= dotprod >> shift; +buffer[i] -= (unsigned)(dotprod >> shift); for (j = 0; j < order - 1; j++) delay[j] = delay[j + 1]; delay[order - 1] = buffer[i]; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/takdsp: Fix integer overflow in decorrelate_sf()
Fixes: signed integer overflow: -101 * 71041254 cannot be represented in type 'int' Fixes: 45938/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-4687974320701440 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/takdsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/takdsp.c b/libavcodec/takdsp.c index 9cb8052596..a8f9dba342 100644 --- a/libavcodec/takdsp.c +++ b/libavcodec/takdsp.c @@ -65,7 +65,7 @@ static void decorrelate_sf(int32_t *p1, int32_t *p2, int length, int dshift, int for (i = 0; i < length; i++) { int32_t a = p1[i]; int32_t b = p2[i]; -b = (unsigned)(dfactor * (b >> dshift) + 128 >> 8) << dshift; +b = (unsigned)((int)(dfactor * (unsigned)(b >> dshift) + 128) >> 8) << dshift; p1[i] = b - a; } } -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/4] avutil: add ambient viewing environment metadata side data
From: Limin Wang Signed-off-by: Limin Wang --- libavutil/frame.c | 1 + libavutil/frame.h | 6 + libavutil/mastering_display_metadata.c | 23 + libavutil/mastering_display_metadata.h | 45 ++ 4 files changed, 75 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index fbb869f..8882da2 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -815,6 +815,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_DETECTION_BBOXES:return "Bounding boxes for object detection and classification"; case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data"; case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata"; +case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: return "Ambient Viewing Environment"; } return NULL; } diff --git a/libavutil/frame.h b/libavutil/frame.h index 33fac20..f7b1d4e 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -209,6 +209,12 @@ enum AVFrameSideDataType { * volume transform - CUVA 005.1-2021. */ AV_FRAME_DATA_DYNAMIC_HDR_VIVID, + +/** + * ambient viewing environment for a video frame, as described by + * the AVAmbientViewingEnvMetadata. + */ +AV_FRAME_DATA_AMBIENT_VIEWING_ENV, }; enum AVActiveFormatDescription { diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c index 6069347..ba1c80f 100644 --- a/libavutil/mastering_display_metadata.c +++ b/libavutil/mastering_display_metadata.c @@ -64,3 +64,26 @@ AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *fram return (AVContentLightMetadata *)side_data->data; } + +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t *size) +{ +AVAmbientViewingEnvMetadata *metadata = av_mallocz(sizeof(*metadata)); + +if (size) +*size = sizeof(*metadata); + +return metadata; +} + +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame) +{ +AVFrameSideData *side_data = av_frame_new_side_data(frame, +AV_FRAME_DATA_AMBIENT_VIEWING_ENV, +sizeof(AVAmbientViewingEnvMetadata)); +if (!side_data) +return NULL; + +memset(side_data->data, 0, sizeof(AVAmbientViewingEnvMetadata)); + +return (AVAmbientViewingEnvMetadata *)side_data->data; +} diff --git a/libavutil/mastering_display_metadata.h b/libavutil/mastering_display_metadata.h index c23b07c..d7598c1 100644 --- a/libavutil/mastering_display_metadata.h +++ b/libavutil/mastering_display_metadata.h @@ -125,4 +125,49 @@ AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size); */ AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame); +/** + * The characteristics of the nominal ambient viewing environment for + * the display of the associated video content. + * To be used as payload of a AVFrameSideData the appropriate type. + * + * @note The struct should be allocated with av_ambient_viewing_env_metadata_alloc() + * and its size is not a part of the public ABI. + */ +typedef struct AVAmbientViewingEnvMetadata { +/** + * specifies the environmental illuminance of the ambient viewing + * environment in units of 0.0001 lux. + * ambient_illuminance shall not be equal to 0. + */ +uint32_t ambient_illuminance; +/** + * specify the normalized x and y chromaticity coordinates, respectively, + * of the environmental ambient light in the nominal viewing environment, + * according to the CIE 1931 definition of x and y as specified in ISO + * 11664-1 (see also ISO 11664-3 and CIE 15), in normalized increments of + * 0.2. The values of ambient_light_x and ambient_light_y shall be in + * the range of 0 to 5 + */ +uint16_t ambient_light_x; +uint16_t ambient_light_y; +} AVAmbientViewingEnvMetadata; + +/** + * Allocate an AVAmbientViewingEnvMetadata structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVAmbientViewingEnvMetadata filled with default values or NULL + * on failure. + */ +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_alloc(size_t *size); + +/** + * Allocate a complete AVAmbientViewingEnvMetadata and add it to the frame. + * + * @param frame The frame which side data is added to. + * + * @return The AVAmbientViewingEnvMetadata structure to be filled by caller. + */ +AVAmbientViewingEnvMetadata *av_ambient_viewing_env_metadata_create_side_data(AVFrame *frame); + #endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */ -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ.
[FFmpeg-devel] [PATCH v2 2/4] avcodec: add support for hevc ambient viewing environment SEI message
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/hevc_sei.c | 19 +++ libavcodec/hevc_sei.h | 8 libavcodec/hevcdec.c | 10 ++ tests/ref/fate/hevc-dv-rpu | 6 ++ 4 files changed, 43 insertions(+) diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index ec3036f..d94df4e 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -497,6 +497,23 @@ static int decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h, return 0; } +static int decode_ambient_viewing_env(HEVCSEIAmbientViewingEnvironment *s, GetBitContext *gb, int size) +{ +if (size < 8) +return AVERROR_INVALIDDATA; + +s->ambient_illuminance = get_bits(gb, 32); +s->ambient_light_x = get_bits(gb, 16); +s->ambient_light_y = get_bits(gb, 16); +size -= 8; + +s->present = 1; + +skip_bits_long(gb, 8 * size); +return 0; +} + + static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, int type, int size) { @@ -525,6 +542,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s, return decode_nal_sei_timecode(&s->timecode, gb); case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS: return decode_film_grain_characteristics(&s->film_grain_characteristics, gb); +case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT: +return decode_ambient_viewing_env(&s->ambient_viewing_env, gb, size); default: av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); skip_bits_long(gb, 8 * size); diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h index f198402..c7623f5 100644 --- a/libavcodec/hevc_sei.h +++ b/libavcodec/hevc_sei.h @@ -134,6 +134,13 @@ typedef struct HEVCSEIFilmGrainCharacteristics { int persistence_flag; } HEVCSEIFilmGrainCharacteristics; +typedef struct HEVCSEIAmbientViewingEnvironment { +int present; +uint32_t ambient_illuminance; +uint16_t ambient_light_x; +uint16_t ambient_light_y; +} HEVCSEIAmbientViewingEnvironment; + typedef struct HEVCSEI { HEVCSEIPictureHash picture_hash; HEVCSEIFramePacking frame_packing; @@ -149,6 +156,7 @@ typedef struct HEVCSEI { HEVCSEIAlternativeTransfer alternative_transfer; HEVCSEITimeCode timecode; HEVCSEIFilmGrainCharacteristics film_grain_characteristics; +HEVCSEIAmbientViewingEnvironment ambient_viewing_env; } HEVCSEI; struct HEVCParamSets; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 09c07ac..13c6642 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2998,6 +2998,15 @@ static int set_side_data(HEVCContext *s) } } +if (s->sei.ambient_viewing_env.present > 0) { +AVAmbientViewingEnvMetadata *metadata = av_ambient_viewing_env_metadata_create_side_data(out); +if (!metadata) +return AVERROR(ENOMEM); +metadata->ambient_illuminance = s->sei.ambient_viewing_env.ambient_illuminance; +metadata->ambient_light_x = s->sei.ambient_viewing_env.ambient_light_x; +metadata->ambient_light_y = s->sei.ambient_viewing_env.ambient_light_y; +} + return 0; } @@ -3800,6 +3809,7 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->sei.mastering_display= s0->sei.mastering_display; s->sei.content_light= s0->sei.content_light; s->sei.alternative_transfer = s0->sei.alternative_transfer; +s->sei.ambient_viewing_env = s0->sei.ambient_viewing_env; ret = export_stream_params_from_sei(s); if (ret < 0) diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu index 1980ab1..6879f71 100644 --- a/tests/ref/fate/hevc-dv-rpu +++ b/tests/ref/fate/hevc-dv-rpu @@ -117,6 +117,9 @@ source_min_pq=0 source_max_pq=3079 source_diagonal=42 [/SIDE_DATA] +[SIDE_DATA] +side_data_type=Ambient Viewing Environment +[/SIDE_DATA] [/FRAME] [FRAME] [SIDE_DATA] @@ -234,4 +237,7 @@ source_min_pq=0 source_max_pq=3079 source_diagonal=42 [/SIDE_DATA] +[SIDE_DATA] +side_data_type=Ambient Viewing Environment +[/SIDE_DATA] [/FRAME] -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 3/4] avfilter/vf_showinfo: add support for ambient viewing environment metadata
From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_showinfo.c | 12 1 file changed, 12 insertions(+) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 12d3931..f11b3d9 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -651,6 +651,15 @@ static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) av_log(ctx, AV_LOG_INFO, "\n"); } +static void dump_ambient_viewing_env_metadata(AVFilterContext *ctx, AVFrameSideData *sd) +{ +const AVAmbientViewingEnvMetadata *metadata = (const AVAmbientViewingEnvMetadata *)sd->data; + +av_log(ctx, AV_LOG_INFO, "Ambient Viewing Environment metadata: \n"); +av_log(ctx, AV_LOG_INFO, "ambient_illuminance=%d, ambient_light_x=%d, ambient_light_y=%d", + metadata->ambient_illuminance, metadata->ambient_light_x, metadata->ambient_light_y); +} + static void update_sample_stats_8(const uint8_t *src, int len, int64_t *sum, int64_t *sum2) { int i; @@ -812,6 +821,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) case AV_FRAME_DATA_DOVI_METADATA: dump_dovi_metadata(ctx, sd); break; +case AV_FRAME_DATA_AMBIENT_VIEWING_ENV: + dump_ambient_viewing_env_metadata(ctx, sd); +break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d " "(%"SIZE_SPECIFIER" bytes)\n", sd->type, sd->size); -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 4/4] fftools/ffprobe: add support for ambient viewing environment metadata
From: Limin Wang Signed-off-by: Limin Wang --- fftools/ffprobe.c | 5 + tests/ref/fate/hevc-dv-rpu | 6 ++ 2 files changed, 11 insertions(+) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 05c167e..39773c4 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2605,6 +2605,11 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, AVContentLightMetadata *metadata = (AVContentLightMetadata *)sd->data; print_int("max_content", metadata->MaxCLL); print_int("max_average", metadata->MaxFALL); +} else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENV) { +AVAmbientViewingEnvMetadata *metadata = (AVAmbientViewingEnvMetadata *)sd->data; +print_int("ambient_illuminance", metadata->ambient_illuminance); +print_int("ambient_light_x", metadata->ambient_light_x); +print_int("ambient_light_y", metadata->ambient_light_y); } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) { const AVDictionaryEntry *tag = av_dict_get(sd->metadata, "name", NULL, AV_DICT_MATCH_CASE); if (tag) diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu index 6879f71..4ad5436 100644 --- a/tests/ref/fate/hevc-dv-rpu +++ b/tests/ref/fate/hevc-dv-rpu @@ -119,6 +119,9 @@ source_diagonal=42 [/SIDE_DATA] [SIDE_DATA] side_data_type=Ambient Viewing Environment +ambient_illuminance=314 +ambient_light_x=15635 +ambient_light_y=16450 [/SIDE_DATA] [/FRAME] [FRAME] @@ -239,5 +242,8 @@ source_diagonal=42 [/SIDE_DATA] [SIDE_DATA] side_data_type=Ambient Viewing Environment +ambient_illuminance=314 +ambient_light_x=15635 +ambient_light_y=16450 [/SIDE_DATA] [/FRAME] -- 1.8.3.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/libvpxenc: enable dynamic max quantizer parameter reconfiguration
On Thu, Mar 24, 2022 at 7:27 PM James Zern wrote: > > On Thu, Mar 24, 2022 at 6:12 AM Danil Chapovalov > wrote: > > > > --- > > libavcodec/libvpxenc.c | 6 ++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > > index dff1d06b0e..463a658bb0 100644 > > --- a/libavcodec/libvpxenc.c > > +++ b/libavcodec/libvpxenc.c > > @@ -1625,6 +1625,12 @@ static int vpx_encode(AVCodecContext *avctx, > > AVPacket *pkt, > > vpx_svc_layer_id_t layer_id; > > int layer_id_valid = 0; > > > > +if (avctx->qmax >= 0 && enccfg->rc_max_quantizer != avctx->qmax) { > > +struct vpx_codec_enc_cfg cfg = *enccfg; > > +cfg.rc_max_quantizer = avctx->qmax; > > +vpx_codec_enc_config_set(&ctx->encoder, &cfg); > > +} > > + > > Jan, I think this was what you were suggesting, no? > The docs could be updated to note qmax can be changed per-frame > [1][2]. Saying that, it does seem a bit unbalanced to only do qmax > here. > > [1] https://ffmpeg.org/ffmpeg-codecs.html#libvpx > [2] > https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/doc/encoders.texi#l2000 As I understand, docs describe command line options. I do not plan to expose changing qmax per frame as a command line option, I do not see how that can be reasonably done. My intent is to change max qp when ffmpeg is used as a library. I agree it looks unbalanced to change just the qmax, but that is the only parameter I currently need for my usecase. Personally I prefer to only add features that are planned to be used. Are there any particular configuration settings you want me to make configurable, or do you think it is better to support all settings that can be configurable? smime.p7s Description: S/MIME Cryptographic Signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/4] avcodec: add support for hevc ambient viewing environment SEI message
On Mon, Mar 28, 2022 at 08:41:09PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/hevc_sei.c | 19 +++ > libavcodec/hevc_sei.h | 8 > libavcodec/hevcdec.c | 10 ++ > tests/ref/fate/hevc-dv-rpu | 6 ++ > 4 files changed, 43 insertions(+) > > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c > index ec3036f..d94df4e 100644 > --- a/libavcodec/hevc_sei.c > +++ b/libavcodec/hevc_sei.c > @@ -497,6 +497,23 @@ static int > decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h, > return 0; > } > > +static int decode_ambient_viewing_env(HEVCSEIAmbientViewingEnvironment *s, > GetBitContext *gb, int size) > +{ > +if (size < 8) > +return AVERROR_INVALIDDATA; > + > +s->ambient_illuminance = get_bits(gb, 32); get_bits_long thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable 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 v7 2/2] avcodec/mjpegenc: support writing ICC profiles
From: Niklas Haas This is mostly straightforward. The major complication is that, as a result of the 16-bit chunk size limitation, ICC profiles may need to be split up into multiple chunks. We also need to make sure to allocate enough extra space in the packet to fit the ICC profile, so modify both mpegvideo_enc.c and ljpegenc.c to take into account this extra overhead, failing cleanly if necessary. Also add a FATE transcode test to ensure that the ICC profile gets written (and read) correctly. Note that this ICC profile is smaller than 64 kB, so this doesn't test the APP2 chunk re-arranging code at all. Signed-off-by: Niklas Haas --- libavcodec/ljpegenc.c| 6 ++-- libavcodec/mjpegenc.c| 3 +- libavcodec/mjpegenc_common.c | 68 ++-- libavcodec/mjpegenc_common.h | 4 ++- libavcodec/mpegvideo_enc.c | 4 ++- tests/fate/image.mak | 6 +++- tests/ref/fate/jpg-icc | 42 ++ 7 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 tests/ref/fate/jpg-icc diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index fad19cbb76..382d291621 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -220,7 +220,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const int height = avctx->height; const int mb_width = (width + s->hsample[0] - 1) / s->hsample[0]; const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0]; -int max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE; +size_t max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE; int ret, header_bits; if(avctx->pix_fmt == AV_PIX_FMT_BGR0 @@ -233,12 +233,14 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, * s->hsample[0] * s->vsample[0]; } +if ((ret = ff_mjpeg_add_icc_profile_size(avctx, pict, &max_pkt_size)) < 0) +return ret; if ((ret = ff_alloc_packet(avctx, pkt, max_pkt_size)) < 0) return ret; init_put_bits(&pb, pkt->data, pkt->size); -ff_mjpeg_encode_picture_header(avctx, &pb, NULL, &s->scantable, +ff_mjpeg_encode_picture_header(avctx, &pb, pict, NULL, &s->scantable, s->pred, s->matrix, s->matrix); header_bits = put_bits_count(&pb); diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index a39b990eea..d35195d52e 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -80,7 +80,7 @@ static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256], static void mjpeg_encode_picture_header(MpegEncContext *s) { -ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->mjpeg_ctx, +ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->picture->f, s->mjpeg_ctx, &s->intra_scantable, 0, s->intra_matrix, s->chroma_intra_matrix); @@ -130,6 +130,7 @@ static void mjpeg_encode_picture_frame(MpegEncContext *s) } bytes_needed = (total_bits + 7) / 8; +ff_mjpeg_add_icc_profile_size(s->avctx, s->picture->f, &bytes_needed); ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed); for (int i = 0; i < m->huff_ncode; i++) { diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c index 7b82644763..8f246c96d5 100644 --- a/libavcodec/mjpegenc_common.c +++ b/libavcodec/mjpegenc_common.c @@ -131,8 +131,41 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, AV_WB16(ptr, size); } -static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p) +enum { +ICC_HDR_SIZE= 16, /* ICC_PROFILE\0 tag + 4 bytes */ +ICC_CHUNK_SIZE = UINT16_MAX - ICC_HDR_SIZE, +ICC_MAX_CHUNKS = UINT8_MAX, +}; + +int ff_mjpeg_add_icc_profile_size(AVCodecContext *avctx, const AVFrame *frame, + size_t *max_pkt_size) { +const AVFrameSideData *sd; +size_t new_pkt_size; +int nb_chunks; +sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE); +if (!sd || !sd->size) +return 0; + +if (sd->size > ICC_MAX_CHUNKS * ICC_CHUNK_SIZE) { +av_log(avctx, AV_LOG_ERROR, "Cannot store %"SIZE_SPECIFIER" byte ICC " + "profile: too large for JPEG\n", + sd->size); +return AVERROR_INVALIDDATA; +} + +nb_chunks = (sd->size + ICC_CHUNK_SIZE - 1) / ICC_CHUNK_SIZE; +new_pkt_size = *max_pkt_size + nb_chunks * (UINT16_MAX + 2 /* APP2 marker */); +if (new_pkt_size < *max_pkt_size) /* overflow */ +return AVERROR_INVALIDDATA; +*max_pkt_size = new_pkt_size; +return 0; +} + +static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p, + const AVFrame *frame) +{ +const AVFrameSideData *sd = NULL; int size; uint8_t *ptr; @@ -162,6 +195,35 @@ static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p) put_bits(p, 8, 0); /* thumbnail
[FFmpeg-devel] [PATCH v7 1/2] avcodec/pngenc: support writing iCCP chunks
From: Niklas Haas We re-use the PNGEncContext.zstream for deflate-related operations. Other than that, the code is pretty straightforward. Special care needs to be taken to avoid writing more than 79 characters of the profile description (the maximum supported). To write the (dynamically sized) deflate-encoded data, we allocate extra space in the packet and use that directly as a scratch buffer. Modify png_write_chunk slightly to allow pre-writing the chunk contents like this. Also add a FATE transcode test to ensure that the ICC profile gets encoded correctly. Signed-off-by: Niklas Haas --- libavcodec/pngenc.c| 91 +- tests/fate/image.mak | 10 - tests/ref/fate/png-icc | 43 3 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 tests/ref/fate/png-icc diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index f67f90cd14..1571673f7c 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -236,7 +236,8 @@ static void png_write_chunk(uint8_t **f, uint32_t tag, bytestream_put_be32(f, av_bswap32(tag)); if (length > 0) { crc = av_crc(crc_table, crc, buf, length); -memcpy(*f, buf, length); +if (*f != buf) +memcpy(*f, buf, length); *f += length; } bytestream_put_be32(f, ~crc); @@ -345,10 +346,54 @@ static int png_get_gama(enum AVColorTransferCharacteristic trc, uint8_t *buf) return 1; } +static int png_write_iccp(AVCodecContext *avctx, const AVFrameSideData *sd) +{ +PNGEncContext *s = avctx->priv_data; +z_stream *const zstream = &s->zstream.zstream; +const AVDictionaryEntry *entry; +const char *name; +uint8_t *start, *buf; +int ret; + +if (!sd || !sd->size) +return 0; +zstream->next_in = sd->data; +zstream->avail_in = sd->size; + +/* write the chunk contents first */ +start = s->bytestream + 8; /* make room for iCCP tag + length */ +buf = start; + +/* profile description */ +entry = av_dict_get(sd->metadata, "name", NULL, 0); +name = (entry && entry->value[0]) ? entry->value : "icc"; +for (int i = 0;; i++) { +char c = (i == 79) ? 0 : name[i]; +bytestream_put_byte(&buf, c); +if (!c) +break; +} + +/* compression method and profile data */ +bytestream_put_byte(&buf, 0); +zstream->next_out = buf; +zstream->avail_out = s->bytestream_end - buf; +ret = deflate(zstream, Z_FINISH); +deflateReset(zstream); +if (ret != Z_STREAM_END) +return AVERROR_EXTERNAL; + +/* rewind to the start and write the chunk header/crc */ +png_write_chunk(&s->bytestream, MKTAG('i', 'C', 'C', 'P'), start, +zstream->next_out - start); +return 0; +} + static int encode_headers(AVCodecContext *avctx, const AVFrame *pict) { AVFrameSideData *side_data; PNGEncContext *s = avctx->priv_data; +int ret; /* write png header */ AV_WB32(s->buf, avctx->width); @@ -401,7 +446,13 @@ static int encode_headers(AVCodecContext *avctx, const AVFrame *pict) if (png_get_gama(pict->color_trc, s->buf)) png_write_chunk(&s->bytestream, MKTAG('g', 'A', 'M', 'A'), s->buf, 4); -/* put the palette if needed */ +side_data = av_frame_get_side_data(pict, AV_FRAME_DATA_ICC_PROFILE); +if ((ret = png_write_iccp(avctx, side_data))) { +av_log(avctx, AV_LOG_WARNING, "Failed writing iCCP chunk\n"); +return ret; +} + +/* put the palette if needed, must be after colorspace information */ if (s->color_type == PNG_COLOR_TYPE_PALETTE) { int has_alpha, alpha, i; unsigned int v; @@ -525,6 +576,38 @@ the_end: return ret; } +static int add_icc_profile_size(AVCodecContext *avctx, const AVFrame *pict, +size_t *max_packet_size) +{ +PNGEncContext *s = avctx->priv_data; +const AVFrameSideData *sd; +const int hdr_size = 128; +size_t new_pkt_size; +uLong bound; + +if (!pict) +return 0; +sd = av_frame_get_side_data(pict, AV_FRAME_DATA_ICC_PROFILE); +if (!sd || !sd->size) +return 0; +if (sd->size > ULONG_MAX) +goto overflow; + +bound = deflateBound(&s->zstream.zstream, sd->size); +if (bound > INT32_MAX - hdr_size) +goto overflow; + +new_pkt_size = *max_packet_size + bound + hdr_size; +if (new_pkt_size < *max_packet_size) +goto overflow; +*max_packet_size = new_pkt_size; +return 0; + +overflow: +av_log(avctx, AV_LOG_WARNING, "ICC profile too large\n"); +return AVERROR_INVALIDDATA; +} + static int encode_png(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { @@ -541,6 +624,8 @@ static int encode_png(AVCodecContext *avctx, AVPacket *pkt, enc_row_size + 12 * (((int64_t)enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) // IDAT * ceil(en
[FFmpeg-devel] [PATCH] libavformat/rtmp: Adding a flag to give user the option to have ffmpeg fail instead of warn when mismatches are found in rtmp url stream or application names.
Hello, this patch was originally from William Martin, I just adapt it to the newest ffmpeg version. Regards Jonathan From 89b441ce47614035a545da1a7ce46c53ccf165e5 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 28 Mar 2022 17:07:57 +0200 Subject: [PATCH] Adding a flag to give user the option to have ffmpeg fail instead of warn when mismatches are found in rtmp url stream or application names. from original: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190925185708.70924-1-unique.will.mar...@gmail.com/ --- libavformat/librtmp.c | 2 ++ libavformat/rtmpproto.c | 28 ++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c index 43013e4..00b4966 100644 --- a/libavformat/librtmp.c +++ b/libavformat/librtmp.c @@ -52,6 +52,7 @@ typedef struct LibRTMPContext { int live; char *temp_filename; int buffer_size; +bool strict_paths; } LibRTMPContext; static void rtmp_log(int level, const char *fmt, va_list args) @@ -333,6 +334,7 @@ static const AVOption options[] = { {"rtmp_swfurl", "URL of the SWF player. By default no value will be sent", OFFSET(swfurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, {"rtmp_swfverify", "URL to player swf file, compute hash/size automatically. (unimplemented)", OFFSET(swfverify), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC}, {"rtmp_tcurl", "URL of the target stream. Defaults to proto://host[:port]/app.", OFFSET(tcurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, +{"rtmp_strict_paths", "Error instead of warn for mismatch on stream or application path in url", OFFSET(strict_paths), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC}, #if CONFIG_NETWORK {"rtmp_buffer_size", "set buffer size in bytes", OFFSET(buffer_size), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, DEC|ENC }, #endif diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index f97e3c3..34433ed 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -132,6 +132,7 @@ typedef struct RTMPContext { char auth_params[500]; int do_reconnect; int auth_tried; +int strict_paths; ///< If true, enforce strict string matching on rtmp stream and application } RTMPContext; #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing @@ -480,9 +481,16 @@ static int read_connect(URLContext *s, RTMPContext *rt) "app", tmpstr, sizeof(tmpstr)); if (ret) av_log(s, AV_LOG_WARNING, "App field not found in connect\n"); -if (!ret && strcmp(tmpstr, rt->app)) -av_log(s, AV_LOG_WARNING, "App field don't match up: %s <-> %s\n", - tmpstr, rt->app); +if (!ret && strcmp(tmpstr, rt->app)) { +if (rt->strict_paths) { +av_log(s, AV_LOG_ERROR, "App field don't match up: %s <-> %s. " + "Exiting since rtmp_strict_paths provided\n", tmpstr, rt->app); +return AVERROR(EIO); +} else { +av_log(s, AV_LOG_WARNING, "App field don't match up: %s <-> %s\n", +tmpstr, rt->app); +} +} ff_rtmp_packet_destroy(&pkt); // Send Window Acknowledgement Size (as defined in specification) @@ -1947,9 +1955,16 @@ static int send_invoke_response(URLContext *s, RTMPPacket *pkt) pchar = s->filename; } pchar++; -if (strcmp(pchar, filename)) -av_log(s, AV_LOG_WARNING, "Unexpected stream %s, expecting" - " %s\n", filename, pchar); +if (strcmp(pchar, filename)) { +if (rt->strict_paths) { +av_log(s, AV_LOG_ERROR, "Unexpected stream %s, expecting %s. " +"Exiting since rtmp_strict_paths provided.\n", filename, pchar); +return AVERROR(EIO); +} else { +av_log(s, AV_LOG_WARNING, "Unexpected stream %s, expecting" +" %s\n", filename, pchar); +} +} } rt->state = STATE_RECEIVING; } @@ -3119,6 +3134,7 @@ static const AVOption rtmp_options[] = { {"listen", "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" }, {"tcp_nodelay", "Use TCP_NODELAY to disable Nagle's algorithm", OFFSET(tcp_nodelay), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC|ENC}, {"timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies -rtmp_listen 1", OFFSET(listen_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC, "rtmp_listen" }, +{"rtmp_strict_paths", "Error instead of warn for mismatch on stream or application path in url", OFFSET(strict_paths), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC}, { NULL }, }; -- 2.35.1 _
[FFmpeg-devel] [PATCH] libavformat/rtmp: Adding a flag to give user the option to have ffmpeg fail instead of warn when mismatches are found in rtmp url stream or application names.
Hello, this patch was originally from William Martin, I just adapt it to the newest ffmpeg version. Regards Jonathan From 89b441ce47614035a545da1a7ce46c53ccf165e5 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 28 Mar 2022 17:07:57 +0200 Subject: [PATCH] Adding a flag to give user the option to have ffmpeg fail instead of warn when mismatches are found in rtmp url stream or application names. from original: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190925185708.70924-1-unique.will.mar...@gmail.com/ --- libavformat/librtmp.c | 2 ++ libavformat/rtmpproto.c | 28 ++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c index 43013e4..00b4966 100644 --- a/libavformat/librtmp.c +++ b/libavformat/librtmp.c @@ -52,6 +52,7 @@ typedef struct LibRTMPContext { int live; char *temp_filename; int buffer_size; +bool strict_paths; } LibRTMPContext; static void rtmp_log(int level, const char *fmt, va_list args) @@ -333,6 +334,7 @@ static const AVOption options[] = { {"rtmp_swfurl", "URL of the SWF player. By default no value will be sent", OFFSET(swfurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, {"rtmp_swfverify", "URL to player swf file, compute hash/size automatically. (unimplemented)", OFFSET(swfverify), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC}, {"rtmp_tcurl", "URL of the target stream. Defaults to proto://host[:port]/app.", OFFSET(tcurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC}, +{"rtmp_strict_paths", "Error instead of warn for mismatch on stream or application path in url", OFFSET(strict_paths), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC}, #if CONFIG_NETWORK {"rtmp_buffer_size", "set buffer size in bytes", OFFSET(buffer_size), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, DEC|ENC }, #endif diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index f97e3c3..34433ed 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -132,6 +132,7 @@ typedef struct RTMPContext { char auth_params[500]; int do_reconnect; int auth_tried; +int strict_paths; ///< If true, enforce strict string matching on rtmp stream and application } RTMPContext; #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing @@ -480,9 +481,16 @@ static int read_connect(URLContext *s, RTMPContext *rt) "app", tmpstr, sizeof(tmpstr)); if (ret) av_log(s, AV_LOG_WARNING, "App field not found in connect\n"); -if (!ret && strcmp(tmpstr, rt->app)) -av_log(s, AV_LOG_WARNING, "App field don't match up: %s <-> %s\n", - tmpstr, rt->app); +if (!ret && strcmp(tmpstr, rt->app)) { +if (rt->strict_paths) { +av_log(s, AV_LOG_ERROR, "App field don't match up: %s <-> %s. " + "Exiting since rtmp_strict_paths provided\n", tmpstr, rt->app); +return AVERROR(EIO); +} else { +av_log(s, AV_LOG_WARNING, "App field don't match up: %s <-> %s\n", +tmpstr, rt->app); +} +} ff_rtmp_packet_destroy(&pkt); // Send Window Acknowledgement Size (as defined in specification) @@ -1947,9 +1955,16 @@ static int send_invoke_response(URLContext *s, RTMPPacket *pkt) pchar = s->filename; } pchar++; -if (strcmp(pchar, filename)) -av_log(s, AV_LOG_WARNING, "Unexpected stream %s, expecting" - " %s\n", filename, pchar); +if (strcmp(pchar, filename)) { +if (rt->strict_paths) { +av_log(s, AV_LOG_ERROR, "Unexpected stream %s, expecting %s. " +"Exiting since rtmp_strict_paths provided.\n", filename, pchar); +return AVERROR(EIO); +} else { +av_log(s, AV_LOG_WARNING, "Unexpected stream %s, expecting" +" %s\n", filename, pchar); +} +} } rt->state = STATE_RECEIVING; } @@ -3119,6 +3134,7 @@ static const AVOption rtmp_options[] = { {"listen", "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" }, {"tcp_nodelay", "Use TCP_NODELAY to disable Nagle's algorithm", OFFSET(tcp_nodelay), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC|ENC}, {"timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies -rtmp_listen 1", OFFSET(listen_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC, "rtmp_listen" }, +{"rtmp_strict_paths", "Error instead of warn for mismatch on stream or application path in url", OFFSET(strict_paths), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC}, { NULL }, }; -- 2.35.1 _
Re: [FFmpeg-devel] [PATCH v9 1/1] avformat: Add IPFS protocol support.
On Fri, Mar 18, 2022 at 03:50:05PM +0100, Mark Gaiser wrote: > This patch adds support for: > - ffplay ipfs:// > - ffplay ipns:// > > IPFS data can be played from so called "ipfs gateways". > A gateway is essentially a webserver that gives access to the > distributed IPFS network. > > This protocol support (ipfs and ipns) therefore translates > ipfs:// and ipns:// to a http:// url. This resulting url is > then handled by the http protocol. It could also be https > depending on the gateway provided. > > To use this protocol, a gateway must be provided. > If you do nothing it will try to find it in your > $HOME/.ipfs/gateway file. The ways to set it manually are: > 1. Define a -gateway to the gateway. > 2. Define $IPFS_GATEWAY with the full http link to the gateway. > 3. Define $IPFS_PATH and point it to the IPFS data path. > 4. Have IPFS running in your local user folder (under $HOME/.ipfs). > > Signed-off-by: Mark Gaiser > --- > configure | 2 + > doc/protocols.texi| 30 > libavformat/Makefile | 2 + > libavformat/ipfsgateway.c | 310 ++ > libavformat/protocols.c | 2 + > 5 files changed, 346 insertions(+) > create mode 100644 libavformat/ipfsgateway.c Theres some trailing whitespace which needs to be removed our git scripts block trailing whitespace in most files [...] > +static int ipfs_close(URLContext *h) > +{ > +IPFSGatewayContext *c = h->priv_data; > +av_free(c->gateway); this results in a double free [...] thx -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact 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 v9 1/1] avformat: Add IPFS protocol support.
On Mon, Mar 28, 2022 at 6:19 PM Michael Niedermayer wrote: > On Fri, Mar 18, 2022 at 03:50:05PM +0100, Mark Gaiser wrote: > > This patch adds support for: > > - ffplay ipfs:// > > - ffplay ipns:// > > > > IPFS data can be played from so called "ipfs gateways". > > A gateway is essentially a webserver that gives access to the > > distributed IPFS network. > > > > This protocol support (ipfs and ipns) therefore translates > > ipfs:// and ipns:// to a http:// url. This resulting url is > > then handled by the http protocol. It could also be https > > depending on the gateway provided. > > > > To use this protocol, a gateway must be provided. > > If you do nothing it will try to find it in your > > $HOME/.ipfs/gateway file. The ways to set it manually are: > > 1. Define a -gateway to the gateway. > > 2. Define $IPFS_GATEWAY with the full http link to the gateway. > > 3. Define $IPFS_PATH and point it to the IPFS data path. > > 4. Have IPFS running in your local user folder (under $HOME/.ipfs). > > > > Signed-off-by: Mark Gaiser > > --- > > configure | 2 + > > doc/protocols.texi| 30 > > libavformat/Makefile | 2 + > > libavformat/ipfsgateway.c | 310 ++ > > libavformat/protocols.c | 2 + > > 5 files changed, 346 insertions(+) > > create mode 100644 libavformat/ipfsgateway.c > > Theres some trailing whitespace which needs to be removed > our git scripts block trailing whitespace in most files > > [...] > > +static int ipfs_close(URLContext *h) > > +{ > > +IPFSGatewayContext *c = h->priv_data; > > +av_free(c->gateway); > > this results in a double free > I believe one of the earlier feedback rounds told me to put it here. It's not free'd anywhere else. Then again, in those earlier rounds I was manipulating c-gateway which right now isn't the case at all anymore. If all that's stopping it from merging is this single line, could you perhaps merge it and remove this line while at it? I'm kinda reluctant to make another patch and wait 1-2 weeks again... > [...] > > thx > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Complexity theory is the science of finding the exact solution to an > approximation. Benchmarking OTOH is finding an approximation of the exact > ___ > 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 v9 1/1] avformat: Add IPFS protocol support.
On Mon, Mar 28, 2022 at 06:34:33PM +0200, Mark Gaiser wrote: > On Mon, Mar 28, 2022 at 6:19 PM Michael Niedermayer > wrote: > > > On Fri, Mar 18, 2022 at 03:50:05PM +0100, Mark Gaiser wrote: > > > This patch adds support for: > > > - ffplay ipfs:// > > > - ffplay ipns:// > > > > > > IPFS data can be played from so called "ipfs gateways". > > > A gateway is essentially a webserver that gives access to the > > > distributed IPFS network. > > > > > > This protocol support (ipfs and ipns) therefore translates > > > ipfs:// and ipns:// to a http:// url. This resulting url is > > > then handled by the http protocol. It could also be https > > > depending on the gateway provided. > > > > > > To use this protocol, a gateway must be provided. > > > If you do nothing it will try to find it in your > > > $HOME/.ipfs/gateway file. The ways to set it manually are: > > > 1. Define a -gateway to the gateway. > > > 2. Define $IPFS_GATEWAY with the full http link to the gateway. > > > 3. Define $IPFS_PATH and point it to the IPFS data path. > > > 4. Have IPFS running in your local user folder (under $HOME/.ipfs). > > > > > > Signed-off-by: Mark Gaiser > > > --- > > > configure | 2 + > > > doc/protocols.texi| 30 > > > libavformat/Makefile | 2 + > > > libavformat/ipfsgateway.c | 310 ++ > > > libavformat/protocols.c | 2 + > > > 5 files changed, 346 insertions(+) > > > create mode 100644 libavformat/ipfsgateway.c > > > > Theres some trailing whitespace which needs to be removed > > our git scripts block trailing whitespace in most files > > > > [...] > > > +static int ipfs_close(URLContext *h) > > > +{ > > > +IPFSGatewayContext *c = h->priv_data; > > > +av_free(c->gateway); > > > > this results in a double free > > > > I believe one of the earlier feedback rounds told me to put it here. > It's not free'd anywhere else. ==22837== Invalid free() / delete / delete[] / realloc() ==22837==at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==22837==by 0x117FF88: av_opt_free (in ffmpeg/ffmpeg_g) ==22837==by 0x5C58CF: ffurl_closep (in ffmpeg/ffmpeg_g) ==22837==by 0x5C5AF2: ffurl_close (in ffmpeg/ffmpeg_g) ==22837==by 0x5CA206: avio_close (in ffmpeg/ffmpeg_g) ==22837==by 0x3021C0: ffmpeg_cleanup (in ffmpeg/ffmpeg_g) ==22837==by 0x2F5FA0: exit_program (in ffmpeg/ffmpeg_g) ==22837==by 0x2E34A1: main (in ffmpeg/ffmpeg_g) ==22837== Address 0x2ced8760 is 0 bytes inside a block of size 17 free'd ==22837==at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==22837==by 0x7372BD: ipfs_close (in ffmpeg/ffmpeg_g) ==22837==by 0x5C588C: ffurl_closep (in ffmpeg/ffmpeg_g) ==22837==by 0x5C5AF2: ffurl_close (in ffmpeg/ffmpeg_g) ==22837==by 0x5CA206: avio_close (in ffmpeg/ffmpeg_g) ==22837==by 0x3021C0: ffmpeg_cleanup (in ffmpeg/ffmpeg_g) ==22837==by 0x2F5FA0: exit_program (in ffmpeg/ffmpeg_g) ==22837==by 0x2E34A1: main (in ffmpeg/ffmpeg_g) ==22837== Block was alloc'd at ==22837==at 0x4C31A3F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==22837==by 0x4C33D84: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==22837==by 0x117E120: av_strdup (in ffmpeg/ffmpeg_g) ==22837==by 0x1181DEF: av_opt_set (in ffmpeg/ffmpeg_g) ==22837==by 0x118272D: av_opt_set_dict2 (in ffmpeg/ffmpeg_g) ==22837==by 0x5C598C: ffurl_open_whitelist (in ffmpeg/ffmpeg_g) ==22837==by 0x5CA4DD: ffio_open_whitelist (in ffmpeg/ffmpeg_g) ==22837==by 0x6B88FB: io_open_default (in ffmpeg/ffmpeg_g) ==22837==by 0x5E0E9E: avformat_open_input (in ffmpeg/ffmpeg_g) ==22837==by 0x2EB32B: open_input_file (in ffmpeg/ffmpeg_g) ==22837==by 0x2EF00B: ffmpeg_parse_options (in ffmpeg/ffmpeg_g) ==22837==by 0x2E3301: main (in ffmpeg/ffmpeg_g) > > Then again, in those earlier rounds I was manipulating c-gateway which > right now isn't the case at all anymore. > > If all that's stopping it from merging is this single line, could you > perhaps merge it and remove this line while at it? > I'm kinda reluctant to make another patch and wait 1-2 weeks again... I do not know why its there or who asked for it to be put there. I dont want to just remove something while merging that someone else asked to be added thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Never trust a computer, one day, it may think you are the virus. -- Compn 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 v9 1/1] avformat: Add IPFS protocol support.
On Mon, Mar 28, 2022 at 6:44 PM Michael Niedermayer wrote: > On Mon, Mar 28, 2022 at 06:34:33PM +0200, Mark Gaiser wrote: > > On Mon, Mar 28, 2022 at 6:19 PM Michael Niedermayer < > mich...@niedermayer.cc> > > wrote: > > > > > On Fri, Mar 18, 2022 at 03:50:05PM +0100, Mark Gaiser wrote: > > > > This patch adds support for: > > > > - ffplay ipfs:// > > > > - ffplay ipns:// > > > > > > > > IPFS data can be played from so called "ipfs gateways". > > > > A gateway is essentially a webserver that gives access to the > > > > distributed IPFS network. > > > > > > > > This protocol support (ipfs and ipns) therefore translates > > > > ipfs:// and ipns:// to a http:// url. This resulting url is > > > > then handled by the http protocol. It could also be https > > > > depending on the gateway provided. > > > > > > > > To use this protocol, a gateway must be provided. > > > > If you do nothing it will try to find it in your > > > > $HOME/.ipfs/gateway file. The ways to set it manually are: > > > > 1. Define a -gateway to the gateway. > > > > 2. Define $IPFS_GATEWAY with the full http link to the gateway. > > > > 3. Define $IPFS_PATH and point it to the IPFS data path. > > > > 4. Have IPFS running in your local user folder (under $HOME/.ipfs). > > > > > > > > Signed-off-by: Mark Gaiser > > > > --- > > > > configure | 2 + > > > > doc/protocols.texi| 30 > > > > libavformat/Makefile | 2 + > > > > libavformat/ipfsgateway.c | 310 > ++ > > > > libavformat/protocols.c | 2 + > > > > 5 files changed, 346 insertions(+) > > > > create mode 100644 libavformat/ipfsgateway.c > > > > > > Theres some trailing whitespace which needs to be removed > > > our git scripts block trailing whitespace in most files > > > > > > [...] > > > > +static int ipfs_close(URLContext *h) > > > > +{ > > > > +IPFSGatewayContext *c = h->priv_data; > > > > +av_free(c->gateway); > > > > > > this results in a double free > > > > > > > I believe one of the earlier feedback rounds told me to put it here. > > It's not free'd anywhere else. > > ==22837== Invalid free() / delete / delete[] / realloc() > ==22837==at 0x4C32D3B: free (in > /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > ==22837==by 0x117FF88: av_opt_free (in ffmpeg/ffmpeg_g) > ==22837==by 0x5C58CF: ffurl_closep (in ffmpeg/ffmpeg_g) > ==22837==by 0x5C5AF2: ffurl_close (in ffmpeg/ffmpeg_g) > ==22837==by 0x5CA206: avio_close (in ffmpeg/ffmpeg_g) > ==22837==by 0x3021C0: ffmpeg_cleanup (in ffmpeg/ffmpeg_g) > ==22837==by 0x2F5FA0: exit_program (in ffmpeg/ffmpeg_g) > ==22837==by 0x2E34A1: main (in ffmpeg/ffmpeg_g) > ==22837== Address 0x2ced8760 is 0 bytes inside a block of size 17 free'd > ==22837==at 0x4C32D3B: free (in > /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > ==22837==by 0x7372BD: ipfs_close (in ffmpeg/ffmpeg_g) > ==22837==by 0x5C588C: ffurl_closep (in ffmpeg/ffmpeg_g) > ==22837==by 0x5C5AF2: ffurl_close (in ffmpeg/ffmpeg_g) > ==22837==by 0x5CA206: avio_close (in ffmpeg/ffmpeg_g) > ==22837==by 0x3021C0: ffmpeg_cleanup (in ffmpeg/ffmpeg_g) > ==22837==by 0x2F5FA0: exit_program (in ffmpeg/ffmpeg_g) > ==22837==by 0x2E34A1: main (in ffmpeg/ffmpeg_g) > ==22837== Block was alloc'd at > ==22837==at 0x4C31A3F: malloc (in > /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > ==22837==by 0x4C33D84: realloc (in > /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > ==22837==by 0x117E120: av_strdup (in ffmpeg/ffmpeg_g) > ==22837==by 0x1181DEF: av_opt_set (in ffmpeg/ffmpeg_g) > ==22837==by 0x118272D: av_opt_set_dict2 (in ffmpeg/ffmpeg_g) > ==22837==by 0x5C598C: ffurl_open_whitelist (in ffmpeg/ffmpeg_g) > ==22837==by 0x5CA4DD: ffio_open_whitelist (in ffmpeg/ffmpeg_g) > ==22837==by 0x6B88FB: io_open_default (in ffmpeg/ffmpeg_g) > ==22837==by 0x5E0E9E: avformat_open_input (in ffmpeg/ffmpeg_g) > ==22837==by 0x2EB32B: open_input_file (in ffmpeg/ffmpeg_g) > ==22837==by 0x2EF00B: ffmpeg_parse_options (in ffmpeg/ffmpeg_g) > ==22837==by 0x2E3301: main (in ffmpeg/ffmpeg_g) > > > > > > Then again, in those earlier rounds I was manipulating c-gateway which > > right now isn't the case at all anymore. > > > > If all that's stopping it from merging is this single line, could you > > perhaps merge it and remove this line while at it? > > I'm kinda reluctant to make another patch and wait 1-2 weeks again... > > I do not know why its there or who asked for it to be put there. > I dont want to just remove something while merging that someone else > asked to be added > It's fine, you can remove it. I just checked with crypto.c (which I use as an example). d->gateway is an AVOption and is never changed in code. If I compare it with other AVOption in crypto.c, it too follows the same concept of never deleting it manually (probably AVOption magic internally?) Removing it is fine. Unless crypto.c does i
Re: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing
On Tue, Mar 22, 2022 at 9:46 AM Vignesh Venkatasubramanian wrote: > > Add an AVIF muxer by re-using the existing the mov/mp4 muxer. > > AVIF Specifiation: https://aomediacodec.github.io/av1-avif > > Sample usage for still image: > ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif > > Sample usage for animated AVIF image: > ffmpeg -i video.mp4 animated.avif > > We can re-use any of the AV1 encoding options that will make > sense for image encoding (like bitrate, tiles, encoding speed, > etc). > > The files generated by this muxer has been verified to be valid > AVIF files by the following: > 1) Displays on Chrome (both still and animated images). > 2) Displays on Firefox (only still images, firefox does not support >animated AVIF yet). > 3) Verfied to be valid by Compliance Warden: >https://github.com/gpac/ComplianceWarden > > Fixes the encoder/muxer part of Trac Ticket #7621 > > Signed-off-by: Vignesh Venkatasubramanian > --- > configure| 1 + > libavformat/allformats.c | 1 + > libavformat/movenc.c | 337 --- > libavformat/movenc.h | 5 + > 4 files changed, 319 insertions(+), 25 deletions(-) > > diff --git a/configure b/configure > index dff53e88bc..5aaf198704 100755 > --- a/configure > +++ b/configure > @@ -3394,6 +3394,7 @@ asf_stream_muxer_select="asf_muxer" > av1_demuxer_select="av1_frame_merge_bsf av1_parser" > avi_demuxer_select="riffdec exif" > avi_muxer_select="riffenc" > +avif_muxer_select="mov_muxer" > caf_demuxer_select="iso_media" > caf_muxer_select="iso_media" > dash_muxer_select="mp4_muxer" > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 587ad59b3c..29e58353ee 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer; > extern const AVInputFormat ff_av1_demuxer; > extern const AVInputFormat ff_avi_demuxer; > extern const AVOutputFormat ff_avi_muxer; > +extern const AVOutputFormat ff_avif_muxer; > extern const AVInputFormat ff_avisynth_demuxer; > extern const AVOutputFormat ff_avm2_muxer; > extern const AVInputFormat ff_avr_demuxer; > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index 1c31f48abb..b9b424bc97 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -1306,7 +1306,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack > *track) > > avio_wb32(pb, 0); > ffio_wfourcc(pb, "av1C"); > -ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1); > +ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != > MODE_AVIF); > return update_size(pb, pos); > } > > @@ -2007,12 +2007,13 @@ static int mov_write_colr_tag(AVIOContext *pb, > MOVTrack *track, int prefer_icc) > } > } > > -/* We should only ever be called by MOV or MP4. */ > -av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4); > +/* We should only ever be called for MOV, MP4 and AVIF. */ > +av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 || > + track->mode == MODE_AVIF); > > avio_wb32(pb, 0); /* size */ > ffio_wfourcc(pb, "colr"); > -if (track->mode == MODE_MP4) > +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) > ffio_wfourcc(pb, "nclx"); > else > ffio_wfourcc(pb, "nclc"); > @@ -2022,7 +2023,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack > *track, int prefer_icc) > avio_wb16(pb, track->par->color_primaries); > avio_wb16(pb, track->par->color_trc); > avio_wb16(pb, track->par->color_space); > -if (track->mode == MODE_MP4) { > +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) { > int full_range = track->par->color_range == AVCOL_RANGE_JPEG; > avio_w8(pb, full_range << 7); > } > @@ -2088,7 +2089,7 @@ static void find_compressor(char * compressor_name, int > len, MOVTrack *track) >|| (track->par->width == 1440 && track->par->height == > 1080) >|| (track->par->width == 1920 && track->par->height == > 1080); > > -if (track->mode == MODE_MOV && > +if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) && > (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) { > av_strlcpy(compressor_name, encoder->value, 32); > } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) { > @@ -2109,6 +2110,25 @@ static void find_compressor(char * compressor_name, > int len, MOVTrack *track) > } > } > > +static int mov_write_ccst_tag(AVIOContext *pb) > +{ > +int64_t pos = avio_tell(pb); > +// Write sane defaults: > +// all_ref_pics_intra = 0 : all samples can use any type of reference. > +// intra_pred_used = 1 : intra prediction may or may not be used. > +// max_ref_per_pic = 15 : reserved value to indicate that any number of > +//reference ima
Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for still image AVIF parsing
On Tue, Mar 22, 2022 at 2:56 PM Vignesh Venkatasubramanian wrote: > > On Wed, Mar 16, 2022 at 10:02 AM Vignesh Venkatasubramanian > wrote: > > > > Add support for parsing AVIF still images. This patches supports > > AVIF still images that have exactly 1 item (i.e.) no alpha channel. > > Essentially, we will have to parse the "iloc" box and populate > > the mov index. > > > > With this patch, we can decode still AVIF images like so: > > ffmpeg -i image.avif image.png > > > > Partially fixes trac ticket #7621 > > > > Signed-off-by: Vignesh Venkatasubramanian > > --- > > libavformat/isom.h | 1 + > > libavformat/mov.c | 142 + > > 2 files changed, 143 insertions(+) > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > index 5caf42b15d..02d681e3ae 100644 > > --- a/libavformat/isom.h > > +++ b/libavformat/isom.h > > @@ -315,6 +315,7 @@ typedef struct MOVContext { > > int have_read_mfra_size; > > uint32_t mfra_size; > > uint32_t max_stts_delta; > > +int is_still_picture_avif; > > } MOVContext; > > > > int ff_mp4_read_descr_len(AVIOContext *pb); > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 6c847de164..3af49427b9 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext > > *pb, MOVAtom atom) > > c->isom = 1; > > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char > > *)&type); > > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > > +c->is_still_picture_avif = !strncmp(type, "avif", 4); > > minor_ver = avio_rb32(pb); /* minor version */ > > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > > > @@ -7430,6 +7431,146 @@ static int mov_read_SAND(MOVContext *c, AVIOContext > > *pb, MOVAtom atom) > > return 0; > > } > > > > +static int rb_size(AVIOContext *pb, uint64_t* value, int size) > > +{ > > +if (size == 0) { > > +*value = 0; > > +} else if (size == 1) { > > +*value = avio_r8(pb); > > +} else if (size == 2) { > > +*value = avio_rb16(pb); > > +} else if (size == 4) { > > +*value = avio_rb32(pb); > > +} else if (size == 8) { > > +*value = avio_rb64(pb); > > +} else { > > +return -1; > > +} > > +return size; > > +} > > + > > +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > +{ > > +int version, offset_size, length_size, base_offset_size, index_size; > > +int item_count, extent_count; > > +uint64_t base_offset, extent_offset, extent_length; > > +int i, j; > > +uint8_t value; > > +AVStream *st; > > +MOVStreamContext *sc; > > + > > +if (!c->is_still_picture_avif) { > > +// * For non-avif, we simply ignore the iloc box. > > +// * For animated avif, we don't care about the iloc box as all the > > +// necessary information can be found in the moov box. > > +return 0; > > +} > > + > > +if (c->fc->nb_streams) { > > +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n"); > > +return 0; > > +} > > + > > +st = avformat_new_stream(c->fc, NULL); > > +if (!st) return AVERROR(ENOMEM); > > +st->id = c->fc->nb_streams; > > +sc = av_mallocz(sizeof(MOVStreamContext)); > > +if (!sc) return AVERROR(ENOMEM); > > + > > +st->priv_data = sc; > > +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > > +st->codecpar->codec_id = AV_CODEC_ID_AV1; > > +sc->ffindex = st->index; > > +c->trak_index = st->index; > > +st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > > +st->time_base.num = st->time_base.den = 1; > > +st->nb_frames = 1; > > +sc->time_scale = 1; > > +sc = st->priv_data; > > +sc->pb = c->fc->pb; > > +sc->pb_is_copied = 1; > > + > > +version = avio_r8(pb); > > +avio_rb24(pb); // flags. > > + > > +value = avio_r8(pb); > > +offset_size = (value >> 4) & 0xF; > > +length_size = value & 0xF; > > +value = avio_r8(pb); > > +base_offset_size = (value >> 4) & 0xF; > > +index_size = (version == 0) ? 0 : (value & 0xF); > > +if (index_size != 0) { > > +return AVERROR_PATCHWELCOME; > > +} > > +item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb); > > +if (item_count > 1) { > > +// For still AVIF images, we only support one item. Second item > > will > > +// generally be found for AVIF images with alpha channel. We don't > > +// support them as of now. > > +return AVERROR_PATCHWELCOME; > > +} > > + > > +// Populate the necessary fields used by mov_build_index. > > +sc->stsc_count = item_count; > > +sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data)); > > +if (!sc->stsc_data) { > > +return AVERROR(ENOMEM); > > +} > > +sc->stsc_data[0].first = 1; > > +sc->stsc_data[0].c
Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for still image AVIF parsing
On Mon, Mar 28, 2022 at 7:07 PM Vignesh Venkatasubramanian < vigneshv-at-google@ffmpeg.org> wrote: > On Tue, Mar 22, 2022 at 2:56 PM Vignesh Venkatasubramanian > wrote: > > > > On Wed, Mar 16, 2022 at 10:02 AM Vignesh Venkatasubramanian > > wrote: > > > > > > Add support for parsing AVIF still images. This patches supports > > > AVIF still images that have exactly 1 item (i.e.) no alpha channel. > > > Essentially, we will have to parse the "iloc" box and populate > > > the mov index. > > > > > > With this patch, we can decode still AVIF images like so: > > > ffmpeg -i image.avif image.png > > > > > > Partially fixes trac ticket #7621 > > > > > > Signed-off-by: Vignesh Venkatasubramanian > > > --- > > > libavformat/isom.h | 1 + > > > libavformat/mov.c | 142 + > > > 2 files changed, 143 insertions(+) > > > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > > index 5caf42b15d..02d681e3ae 100644 > > > --- a/libavformat/isom.h > > > +++ b/libavformat/isom.h > > > @@ -315,6 +315,7 @@ typedef struct MOVContext { > > > int have_read_mfra_size; > > > uint32_t mfra_size; > > > uint32_t max_stts_delta; > > > +int is_still_picture_avif; > > > } MOVContext; > > > > > > int ff_mp4_read_descr_len(AVIOContext *pb); > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > > index 6c847de164..3af49427b9 100644 > > > --- a/libavformat/mov.c > > > +++ b/libavformat/mov.c > > > @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, > AVIOContext *pb, MOVAtom atom) > > > c->isom = 1; > > > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: > %.4s\n",(char *)&type); > > > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > > > +c->is_still_picture_avif = !strncmp(type, "avif", 4); > > > minor_ver = avio_rb32(pb); /* minor version */ > > > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > > > > > @@ -7430,6 +7431,146 @@ static int mov_read_SAND(MOVContext *c, > AVIOContext *pb, MOVAtom atom) > > > return 0; > > > } > > > > > > +static int rb_size(AVIOContext *pb, uint64_t* value, int size) > > > +{ > > > +if (size == 0) { > > > +*value = 0; > > > +} else if (size == 1) { > > > +*value = avio_r8(pb); > > > +} else if (size == 2) { > > > +*value = avio_rb16(pb); > > > +} else if (size == 4) { > > > +*value = avio_rb32(pb); > > > +} else if (size == 8) { > > > +*value = avio_rb64(pb); > > > +} else { > > > +return -1; > > > +} > > > +return size; > > > +} > > > + > > > +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > > +{ > > > +int version, offset_size, length_size, base_offset_size, > index_size; > > > +int item_count, extent_count; > > > +uint64_t base_offset, extent_offset, extent_length; > > > +int i, j; > > > +uint8_t value; > > > +AVStream *st; > > > +MOVStreamContext *sc; > > > + > > > +if (!c->is_still_picture_avif) { > > > +// * For non-avif, we simply ignore the iloc box. > > > +// * For animated avif, we don't care about the iloc box as > all the > > > +// necessary information can be found in the moov box. > > > +return 0; > > > +} > > > + > > > +if (c->fc->nb_streams) { > > > +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n"); > > > +return 0; > > > +} > > > + > > > +st = avformat_new_stream(c->fc, NULL); > > > +if (!st) return AVERROR(ENOMEM); > > > +st->id = c->fc->nb_streams; > > > +sc = av_mallocz(sizeof(MOVStreamContext)); > > > +if (!sc) return AVERROR(ENOMEM); > > > + > > > +st->priv_data = sc; > > > +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > > > +st->codecpar->codec_id = AV_CODEC_ID_AV1; > > > +sc->ffindex = st->index; > > > +c->trak_index = st->index; > > > +st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > > > +st->time_base.num = st->time_base.den = 1; > > > +st->nb_frames = 1; > > > +sc->time_scale = 1; > > > +sc = st->priv_data; > > > +sc->pb = c->fc->pb; > > > +sc->pb_is_copied = 1; > > > + > > > +version = avio_r8(pb); > > > +avio_rb24(pb); // flags. > > > + > > > +value = avio_r8(pb); > > > +offset_size = (value >> 4) & 0xF; > > > +length_size = value & 0xF; > > > +value = avio_r8(pb); > > > +base_offset_size = (value >> 4) & 0xF; > > > +index_size = (version == 0) ? 0 : (value & 0xF); > > > +if (index_size != 0) { > > > +return AVERROR_PATCHWELCOME; > > > +} > > > +item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb); > > > +if (item_count > 1) { > > > +// For still AVIF images, we only support one item. Second > item will > > > +// generally be found for AVIF images with alpha channel. We > don't > > > +// support them as of now. > > > +return AVERROR_PATCH
Re: [FFmpeg-devel] [PATCH 3/5] avcodec/vmdaudio: Fix channels count bug
On Mon, Mar 21, 2022 at 09:19:44PM +0100, Michael Niedermayer wrote: > Fixes: division by zero > Fixes: > 45811/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VMDAUDIO_fuzzer-6412592581574656 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/vmdaudio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus 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] avformat/mov: Add support for still image AVIF parsing
On Mon, Mar 28, 2022 at 10:11 AM Paul B Mahol wrote: > > On Mon, Mar 28, 2022 at 7:07 PM Vignesh Venkatasubramanian < > vigneshv-at-google@ffmpeg.org> wrote: > > > On Tue, Mar 22, 2022 at 2:56 PM Vignesh Venkatasubramanian > > wrote: > > > > > > On Wed, Mar 16, 2022 at 10:02 AM Vignesh Venkatasubramanian > > > wrote: > > > > > > > > Add support for parsing AVIF still images. This patches supports > > > > AVIF still images that have exactly 1 item (i.e.) no alpha channel. > > > > Essentially, we will have to parse the "iloc" box and populate > > > > the mov index. > > > > > > > > With this patch, we can decode still AVIF images like so: > > > > ffmpeg -i image.avif image.png > > > > > > > > Partially fixes trac ticket #7621 > > > > > > > > Signed-off-by: Vignesh Venkatasubramanian > > > > --- > > > > libavformat/isom.h | 1 + > > > > libavformat/mov.c | 142 + > > > > 2 files changed, 143 insertions(+) > > > > > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > > > index 5caf42b15d..02d681e3ae 100644 > > > > --- a/libavformat/isom.h > > > > +++ b/libavformat/isom.h > > > > @@ -315,6 +315,7 @@ typedef struct MOVContext { > > > > int have_read_mfra_size; > > > > uint32_t mfra_size; > > > > uint32_t max_stts_delta; > > > > +int is_still_picture_avif; > > > > } MOVContext; > > > > > > > > int ff_mp4_read_descr_len(AVIOContext *pb); > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > > > index 6c847de164..3af49427b9 100644 > > > > --- a/libavformat/mov.c > > > > +++ b/libavformat/mov.c > > > > @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, > > AVIOContext *pb, MOVAtom atom) > > > > c->isom = 1; > > > > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: > > %.4s\n",(char *)&type); > > > > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > > > > +c->is_still_picture_avif = !strncmp(type, "avif", 4); > > > > minor_ver = avio_rb32(pb); /* minor version */ > > > > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > > > > > > > @@ -7430,6 +7431,146 @@ static int mov_read_SAND(MOVContext *c, > > AVIOContext *pb, MOVAtom atom) > > > > return 0; > > > > } > > > > > > > > +static int rb_size(AVIOContext *pb, uint64_t* value, int size) > > > > +{ > > > > +if (size == 0) { > > > > +*value = 0; > > > > +} else if (size == 1) { > > > > +*value = avio_r8(pb); > > > > +} else if (size == 2) { > > > > +*value = avio_rb16(pb); > > > > +} else if (size == 4) { > > > > +*value = avio_rb32(pb); > > > > +} else if (size == 8) { > > > > +*value = avio_rb64(pb); > > > > +} else { > > > > +return -1; > > > > +} > > > > +return size; > > > > +} > > > > + > > > > +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > > > +{ > > > > +int version, offset_size, length_size, base_offset_size, > > index_size; > > > > +int item_count, extent_count; > > > > +uint64_t base_offset, extent_offset, extent_length; > > > > +int i, j; > > > > +uint8_t value; > > > > +AVStream *st; > > > > +MOVStreamContext *sc; > > > > + > > > > +if (!c->is_still_picture_avif) { > > > > +// * For non-avif, we simply ignore the iloc box. > > > > +// * For animated avif, we don't care about the iloc box as > > all the > > > > +// necessary information can be found in the moov box. > > > > +return 0; > > > > +} > > > > + > > > > +if (c->fc->nb_streams) { > > > > +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n"); > > > > +return 0; > > > > +} > > > > + > > > > +st = avformat_new_stream(c->fc, NULL); > > > > +if (!st) return AVERROR(ENOMEM); > > > > +st->id = c->fc->nb_streams; > > > > +sc = av_mallocz(sizeof(MOVStreamContext)); > > > > +if (!sc) return AVERROR(ENOMEM); > > > > + > > > > +st->priv_data = sc; > > > > +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > > > > +st->codecpar->codec_id = AV_CODEC_ID_AV1; > > > > +sc->ffindex = st->index; > > > > +c->trak_index = st->index; > > > > +st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > > > > +st->time_base.num = st->time_base.den = 1; > > > > +st->nb_frames = 1; > > > > +sc->time_scale = 1; > > > > +sc = st->priv_data; > > > > +sc->pb = c->fc->pb; > > > > +sc->pb_is_copied = 1; > > > > + > > > > +version = avio_r8(pb); > > > > +avio_rb24(pb); // flags. > > > > + > > > > +value = avio_r8(pb); > > > > +offset_size = (value >> 4) & 0xF; > > > > +length_size = value & 0xF; > > > > +value = avio_r8(pb); > > > > +base_offset_size = (value >> 4) & 0xF; > > > > +index_size = (version == 0) ? 0 : (value & 0xF); > > > > +if (index_size != 0) { > > > > +return AVERROR_PATCHWELCOME; > > > > +} > > > > +item_count = (version < 2
[FFmpeg-devel] [PATCH] avformat/mov: Add support for still image AVIF parsing
Add support for parsing AVIF still images. This patches supports AVIF still images that have exactly 1 item (i.e.) no alpha channel. Essentially, we will have to parse the "iloc" box and populate the mov index. With this patch, we can decode still AVIF images like so: ffmpeg -i image.avif image.png Partially fixes trac ticket #7621 Signed-off-by: Vignesh Venkatasubramanian --- libavformat/isom.h | 1 + libavformat/mov.c | 142 + 2 files changed, 143 insertions(+) diff --git a/libavformat/isom.h b/libavformat/isom.h index 5caf42b15d..02d681e3ae 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -315,6 +315,7 @@ typedef struct MOVContext { int have_read_mfra_size; uint32_t mfra_size; uint32_t max_stts_delta; +int is_still_picture_avif; } MOVContext; int ff_mp4_read_descr_len(AVIOContext *pb); diff --git a/libavformat/mov.c b/libavformat/mov.c index 6c847de164..eb9a529ceb 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) c->isom = 1; av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); av_dict_set(&c->fc->metadata, "major_brand", type, 0); +c->is_still_picture_avif = !strncmp(type, "avif", 4); minor_ver = avio_rb32(pb); /* minor version */ av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); @@ -7430,6 +7431,146 @@ static int mov_read_SAND(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int rb_size(AVIOContext *pb, uint64_t* value, int size) +{ +if (size == 0) { +*value = 0; +} else if (size == 1) { +*value = avio_r8(pb); +} else if (size == 2) { +*value = avio_rb16(pb); +} else if (size == 4) { +*value = avio_rb32(pb); +} else if (size == 8) { +*value = avio_rb64(pb); +} else { +return -1; +} +return size; +} + +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +int version, offset_size, length_size, base_offset_size, index_size; +int item_count, extent_count; +uint64_t base_offset, extent_offset, extent_length; +int i, j; +uint8_t value; +AVStream *st; +MOVStreamContext *sc; + +if (!c->is_still_picture_avif) { +// * For non-avif, we simply ignore the iloc box. +// * For animated avif, we don't care about the iloc box as all the +// necessary information can be found in the moov box. +return 0; +} + +if (c->fc->nb_streams) { +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n"); +return 0; +} + +st = avformat_new_stream(c->fc, NULL); +if (!st) return AVERROR(ENOMEM); +st->id = c->fc->nb_streams; +sc = av_mallocz(sizeof(MOVStreamContext)); +if (!sc) return AVERROR(ENOMEM); + +st->priv_data = sc; +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; +st->codecpar->codec_id = AV_CODEC_ID_AV1; +sc->ffindex = st->index; +c->trak_index = st->index; +st->avg_frame_rate.num = st->avg_frame_rate.den = 1; +st->time_base.num = st->time_base.den = 1; +st->nb_frames = 1; +sc->time_scale = 1; +sc = st->priv_data; +sc->pb = c->fc->pb; +sc->pb_is_copied = 1; + +version = avio_r8(pb); +avio_rb24(pb); // flags. + +value = avio_r8(pb); +offset_size = (value >> 4) & 0xF; +length_size = value & 0xF; +value = avio_r8(pb); +base_offset_size = (value >> 4) & 0xF; +index_size = (version == 0) ? 0 : (value & 0xF); +if (index_size != 0) { +return AVERROR_PATCHWELCOME; +} +item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb); +if (item_count > 1) { +// For still AVIF images, we only support one item. Second item will +// generally be found for AVIF images with alpha channel. We don't +// support them as of now. +return AVERROR_PATCHWELCOME; +} + +// Populate the necessary fields used by mov_build_index. +sc->stsc_count = item_count; +sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data)); +if (!sc->stsc_data) { +return AVERROR(ENOMEM); +} +sc->stsc_data[0].first = 1; +sc->stsc_data[0].count = 1; +sc->stsc_data[0].id = 1; +sc->chunk_count = item_count; +sc->chunk_offsets = av_malloc_array(item_count, sizeof(*sc->chunk_offsets)); +if (!sc->chunk_offsets) { +return AVERROR(ENOMEM); +} +sc->sample_count = item_count; +sc->sample_sizes = av_malloc_array(item_count, sizeof(*sc->sample_sizes)); +if (!sc->sample_sizes) { +return AVERROR(ENOMEM); +} +sc->stts_count = item_count; +sc->stts_data = av_malloc_array(item_count, sizeof(*sc->stts_data)); +if (!sc->stts_data) { +return AVERROR(ENOMEM); +} +sc->stts_data[0].count = 1; +sc->stts_data[0].duration = 0; // Not used
Re: [FFmpeg-devel] [PATCH 01/10] checkasm: Add vc1dsp in-loop deblocking filter tests
On 25/03/2022 22:53, Martin Storsjö wrote: On Fri, 25 Mar 2022, Ben Avison wrote: +#define CHECK_LOOP_FILTER(func) \ + do { \ + if (check_func(h.func, "vc1dsp." #func)) { \ + declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, int, int); \ + for (int count = 1000; count > 0; --count) { \ + int pq = rnd() % 31 + 1; \ + RANDOMIZE_BUFFER8_MID_WEIGHTED(filter_buf, 24 * 24); \ + call_ref(filter_buf0 + 4 * 24 + 4, 24, pq); \ + call_new(filter_buf1 + 4 * 24 + 4, 24, pq); \ + if (memcmp(filter_buf0, filter_buf1, 24 * 24)) \ + fail(); \ + } \ + } \ + for (int j = 0; j < 24; ++j) \ + for (int i = 0; i < 24; ++i) \ + filter_buf1[24*j + i] = 0x60 + 0x40 * (i >= 4 && j >= 4); \ + if (check_func(h.func, "vc1dsp." #func "_bestcase")) { \ + declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, int, int); \ + bench_new(filter_buf1 + 4 * 24 + 4, 24, 1); \ + (void) checked_call; \ + } \ + if (check_func(h.func, "vc1dsp." #func "_worstcase")) { \ + declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, int, int); \ + bench_new(filter_buf1 + 4 * 24 + 4, 24, 31); \ + (void) checked_call; \ + } \ (not a full review, just something that cropped up in initial build testing) Why do you have the "(void) checked_call;" here? The checked_call isn't something that is universally defined; its availability depends on the OS/arch combinations, on other combinations, call_new/call_ref just call the function straight away without a wrapper. OK, I missed that subtlety. My aim was to avoid the "unused variable" compiler warnings generated as a result of there being twice as many benchmark tests as correctness tests. I believe we need separate calls of check_func() to initialise the cycle counts for each benchmark, and copying the sequence of macros from checkasm/blockdsp.c, I was placing the declare_func_emms() invocations inside the if block that used check_func(). That meant that checked_call was initialised, but since the correctness test (call_ref / call_new) was in a different block scope, this checked_call declaration was never used. Upon further investigation, I think it's valid to move the declare_func_emms() invocation up to the next largest block scope. That means it would only appear once rather than 3 times, and it wouldn't need the cast-to-void any more. Please do correct me if I'm wrong. Ben ___ 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] MAINTAINERS: add Niklas Haas for vf_libplacebo.c
From: Niklas Haas So I can merge my own changes to this filter after they pass peer review, as well as keeping it in sync with upstream API changes / new features. Signed-off-by: Niklas Haas --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 931cf4bd2c..76e1332ad8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -354,6 +354,7 @@ Filters: vf_il.c Paul B Mahol vf_(t)interlace Thomas Mundt (CC ) vf_lenscorrection.c Daniel Oberhoff + vf_libplacebo.c Niklas Haas vf_mergeplanes.c Paul B Mahol vf_mestimate.cDavinder Singh vf_minterpolate.c Davinder Singh @@ -620,6 +621,7 @@ Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464 Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB Nicolas George24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93 +Niklas Haas (haasn) 1DDB 8076 B14D 5B48 32FC 99D9 EB52 DA9C 02BA 6FB4 Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1 Panagiotis Issaris6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029 Peter RossA907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/mov: Add support for still image AVIF parsing
Add support for parsing AVIF still images. This patches supports AVIF still images that have exactly 1 item (i.e.) no alpha channel. Essentially, we will have to parse the "iloc" box and populate the mov index. With this patch, we can decode still AVIF images like so: ffmpeg -i image.avif image.png Partially fixes trac ticket #7621 Signed-off-by: Vignesh Venkatasubramanian --- libavformat/isom.h | 1 + libavformat/mov.c | 148 + 2 files changed, 149 insertions(+) diff --git a/libavformat/isom.h b/libavformat/isom.h index 5caf42b15d..02d681e3ae 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -315,6 +315,7 @@ typedef struct MOVContext { int have_read_mfra_size; uint32_t mfra_size; uint32_t max_stts_delta; +int is_still_picture_avif; } MOVContext; int ff_mp4_read_descr_len(AVIOContext *pb); diff --git a/libavformat/mov.c b/libavformat/mov.c index 6c847de164..fb6d071b95 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) c->isom = 1; av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); av_dict_set(&c->fc->metadata, "major_brand", type, 0); +c->is_still_picture_avif = !strncmp(type, "avif", 4); minor_ver = avio_rb32(pb); /* minor version */ av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); @@ -7430,6 +7431,152 @@ static int mov_read_SAND(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int rb_size(AVIOContext *pb, uint64_t* value, int size) +{ +if (size == 0) { +*value = 0; +} else if (size == 1) { +*value = avio_r8(pb); +} else if (size == 2) { +*value = avio_rb16(pb); +} else if (size == 4) { +*value = avio_rb32(pb); +} else if (size == 8) { +*value = avio_rb64(pb); +} else { +return -1; +} +return size; +} + +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +int version, offset_size, length_size, base_offset_size, index_size; +int item_count, extent_count; +uint64_t base_offset, extent_offset, extent_length; +uint8_t value; +AVStream *st; +MOVStreamContext *sc; + +if (!c->is_still_picture_avif) { +// * For non-avif, we simply ignore the iloc box. +// * For animated avif, we don't care about the iloc box as all the +// necessary information can be found in the moov box. +return 0; +} + +if (c->fc->nb_streams) { +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n"); +return 0; +} + +st = avformat_new_stream(c->fc, NULL); +if (!st) { +return AVERROR(ENOMEM); +} +st->id = c->fc->nb_streams; +sc = av_mallocz(sizeof(MOVStreamContext)); +if (!sc) { +return AVERROR(ENOMEM); +} + +st->priv_data = sc; +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; +st->codecpar->codec_id = AV_CODEC_ID_AV1; +sc->ffindex = st->index; +c->trak_index = st->index; +st->avg_frame_rate.num = st->avg_frame_rate.den = 1; +st->time_base.num = st->time_base.den = 1; +st->nb_frames = 1; +sc->time_scale = 1; +sc = st->priv_data; +sc->pb = c->fc->pb; +sc->pb_is_copied = 1; + +version = avio_r8(pb); +avio_rb24(pb); // flags. + +value = avio_r8(pb); +offset_size = (value >> 4) & 0xF; +length_size = value & 0xF; +value = avio_r8(pb); +base_offset_size = (value >> 4) & 0xF; +index_size = !version ? 0 : (value & 0xF); +if (index_size) { +return AVERROR_PATCHWELCOME; +} +item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb); +if (item_count > 1) { +// For still AVIF images, we only support one item. Second item will +// generally be found for AVIF images with alpha channel. We don't +// support them as of now. +return AVERROR_PATCHWELCOME; +} + +// Populate the necessary fields used by mov_build_index. +sc->stsc_count = item_count; +sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data)); +if (!sc->stsc_data) { +return AVERROR(ENOMEM); +} +sc->stsc_data[0].first = 1; +sc->stsc_data[0].count = 1; +sc->stsc_data[0].id = 1; +sc->chunk_count = item_count; +sc->chunk_offsets = +av_malloc_array(item_count, sizeof(*sc->chunk_offsets)); +if (!sc->chunk_offsets) { +return AVERROR(ENOMEM); +} +sc->sample_count = item_count; +sc->sample_sizes = +av_malloc_array(item_count, sizeof(*sc->sample_sizes)); +if (!sc->sample_sizes) { +return AVERROR(ENOMEM); +} +sc->stts_count = item_count; +sc->stts_data = av_malloc_array(item_count, sizeof(*sc->stts_data)); +if (!sc->stts_data) { +return AVERROR(ENOMEM); +} +sc->stts_data[0].count = 1; +// Not used for s
[FFmpeg-devel] [PATCH] avcodec/binkaudio: reset ch_offset on errors
Fixes: NULL pointer dereference Fixes: 45955/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINKAUDIO_DCT_fuzzer-4842044192849920 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/binkaudio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index 56b58b57c8..c4f3e743e2 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -329,6 +329,7 @@ again: avctx->codec->id == AV_CODEC_ID_BINKAUDIO_DCT, FFMIN(MAX_CHANNELS, s->channels - s->ch_offset), s->ch_offset)) { av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n"); +s->ch_offset = 0; return AVERROR_INVALIDDATA; } s->ch_offset += MAX_CHANNELS; @@ -347,6 +348,7 @@ again: return 0; fail: +s->ch_offset = 0; av_packet_unref(s->pkt); return ret; } -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/binkaudio: reset ch_offset on errors
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] MAINTAINERS: add Niklas Haas for vf_libplacebo.c
On 3/28/2022 3:33 PM, Niklas Haas wrote: From: Niklas Haas So I can merge my own changes to this filter after they pass peer review, as well as keeping it in sync with upstream API changes / new features. Signed-off-by: Niklas Haas --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 931cf4bd2c..76e1332ad8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -354,6 +354,7 @@ Filters: vf_il.c Paul B Mahol vf_(t)interlace Thomas Mundt (CC ) vf_lenscorrection.c Daniel Oberhoff + vf_libplacebo.c Niklas Haas vf_mergeplanes.c Paul B Mahol vf_mestimate.cDavinder Singh vf_minterpolate.c Davinder Singh @@ -620,6 +621,7 @@ Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464 Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB Nicolas George24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93 +Niklas Haas (haasn) 1DDB 8076 B14D 5B48 32FC 99D9 EB52 DA9C 02BA 6FB4 Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1 Panagiotis Issaris6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029 Peter RossA907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B Applied. ___ 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] MAINTAINERS: add Niklas Haas for vf_libplacebo.c
28 Mar 2022, 22:14 by jamr...@gmail.com: > On 3/28/2022 3:33 PM, Niklas Haas wrote: > >> From: Niklas Haas >> >> So I can merge my own changes to this filter after they pass peer >> review, as well as keeping it in sync with upstream API changes / new >> features. >> >> Signed-off-by: Niklas Haas >> --- >> MAINTAINERS | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 931cf4bd2c..76e1332ad8 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -354,6 +354,7 @@ Filters: >> vf_il.c Paul B Mahol >> vf_(t)interlace Thomas Mundt (CC ) >> vf_lenscorrection.c Daniel Oberhoff >> + vf_libplacebo.c Niklas Haas >> vf_mergeplanes.c Paul B Mahol >> vf_mestimate.cDavinder Singh >> vf_minterpolate.c Davinder Singh >> @@ -620,6 +621,7 @@ Loren Merritt ABD9 08F4 C920 3F65 D8BE >> 35D7 1540 DAA7 060F 56DE >> Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 >> 4464 >> Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B >> 0FAB >> Nicolas George24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 >> 4C93 >> +Niklas Haas (haasn) 1DDB 8076 B14D 5B48 32FC 99D9 EB52 DA9C 02BA >> 6FB4 >> Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 >> 13B1 >> Panagiotis Issaris6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 >> E029 >> Peter RossA907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 >> DD6B >> > > Applied. > I'm not okay with this. I don't mind anyone pushing approved patches, but I still want to review and have final say on all Vulkan code. Could you change that? I think haasn was more of a maintainer on the film grain stuff. ___ 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 v8 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi
These functions are going to be used in libavformat/avisynth.c and fftools/cmdutils.c remove MAX_PATH limit. --- libavutil/wchar_filename.h | 51 ++ 1 file changed, 51 insertions(+) diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h index 90f0824..e22ffa8 100644 --- a/libavutil/wchar_filename.h +++ b/libavutil/wchar_filename.h @@ -40,6 +40,57 @@ static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w) MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars); return 0; } + +av_warn_unused_result +static inline int wchartocp(const unsigned int code_page, const wchar_t *filename_w, +char **filename) +{ +const DWORD flags = code_page == CP_UTF8 ? MB_ERR_INVALID_CHARS : 0; +const int num_chars = WideCharToMultiByte(code_page, flags, filename_w, -1, + NULL, 0, NULL, NULL); +if (num_chars <= 0) { +*filename = NULL; +return 0; +} +*filename = av_calloc(num_chars, sizeof(char)); +if (!*filename) { +errno = ENOMEM; +return -1; +} +WideCharToMultiByte(code_page, flags, filename_w, -1, +*filename, num_chars, NULL, NULL); +return 0; +} + +av_warn_unused_result +static inline int wchartoutf8(const wchar_t *filename_w, char **filename) +{ +return wchartocp(CP_UTF8, filename_w, filename); +} + +av_warn_unused_result +static inline int wchartoansi(const wchar_t *filename_w, char **filename) +{ +return wchartocp(CP_THREAD_ACP, filename_w, filename); +} + +av_warn_unused_result +static inline int utf8toansi(const char *filename_utf8, char **filename) +{ +wchar_t *filename_w = NULL; +int ret = -1; +if (utf8towchar(filename_utf8, &filename_w)) +return -1; + +if (!filename_w) { +*filename = NULL; +return 0; +} + +ret = wchartoansi(filename_w, filename); +av_free(filename_w); +return ret; +} #endif #endif /* AVUTIL_WCHAR_FILENAME_H */ -- 2.32.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 v8 2/6] libavformat/avisynth.c: Remove MAX_PATH limit
--- libavformat/avisynth.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 8ba2bde..f7bea8c 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -34,6 +34,7 @@ /* Platform-specific directives. */ #ifdef _WIN32 #include "compat/w32dlfcn.h" + #include "libavutil/wchar_filename.h" #undef EXTERN_C #define AVISYNTH_LIB "avisynth" #else @@ -810,8 +811,7 @@ static int avisynth_open_file(AVFormatContext *s) AVS_Value arg, val; int ret; #ifdef _WIN32 -char filename_ansi[MAX_PATH * 4]; -wchar_t filename_wc[MAX_PATH * 4]; +char *filename_ansi = NULL; #endif if (ret = avisynth_context_create(s)) @@ -819,10 +819,12 @@ static int avisynth_open_file(AVFormatContext *s) #ifdef _WIN32 /* Convert UTF-8 to ANSI code page */ -MultiByteToWideChar(CP_UTF8, 0, s->url, -1, filename_wc, MAX_PATH * 4); -WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi, -MAX_PATH * 4, NULL, NULL); +if (utf8toansi(s->url, &filename_ansi)) { +ret = AVERROR_UNKNOWN; +goto fail; +} arg = avs_new_value_string(filename_ansi); +av_free(filename_ansi); #else arg = avs_new_value_string(s->url); #endif -- 2.32.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 v8 3/6] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW
--- compat/w32dlfcn.h | 78 ++- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h index 52a94ef..0f41f50 100644 --- a/compat/w32dlfcn.h +++ b/compat/w32dlfcn.h @@ -25,6 +25,30 @@ #if (_WIN32_WINNT < 0x0602) || HAVE_WINRT #include "libavutil/wchar_filename.h" #endif + +static inline wchar_t *get_module_filename(const HMODULE module) +{ +wchar_t *path = NULL, *new_path = NULL; +DWORD path_size = 0, path_len = 0; + +do { +path_size = path_size ? 2 * path_size : MAX_PATH; +new_path = av_realloc_array(path, path_size, sizeof *path); +if (!new_path) { +av_free(path); +return NULL; +} +path = new_path; +path_len = GetModuleFileNameW(module, path, path_size); +} while (path_len && path_size <= 32768 && path_size <= path_len); + +if (!path_len) { +av_free(path); +return NULL; +} +return path; +} + /** * Safe function used to open dynamic libs. This attempts to improve program security * by removing the current directory from the dll search path. Only dll's found in the @@ -34,29 +58,53 @@ */ static inline HMODULE win32_dlopen(const char *name) { +wchar_t *name_w = NULL; +if (utf8towchar(name, &name_w)) +name_w = NULL; #if _WIN32_WINNT < 0x0602 // Need to check if KB2533623 is available if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) { HMODULE module = NULL; -wchar_t *path = NULL, *name_w = NULL; -DWORD pathlen; -if (utf8towchar(name, &name_w)) +wchar_t *path = NULL, *new_path = NULL; +DWORD pathlen, pathsize, namelen; +if (!name_w) goto exit; -path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t)); +namelen = wcslen(name_w); // Try local directory first -pathlen = GetModuleFileNameW(NULL, path, MAX_PATH); -pathlen = wcsrchr(path, '\\') - path; -if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH) +path = get_module_filename(NULL); +if (!path) goto exit; -path[pathlen] = '\\'; +new_path = wcsrchr(path, '\\'); +if (!new_path) +goto exit; +pathlen = new_path - path; +pathsize = pathlen + namelen + 2; +new_path = av_realloc_array(path, pathsize, sizeof *path); +if (!new_path) +goto exit; +path = new_path; wcscpy(path + pathlen + 1, name_w); module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (module == NULL) { // Next try System32 directory -pathlen = GetSystemDirectoryW(path, MAX_PATH); -if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH) +pathlen = GetSystemDirectoryW(path, pathsize); +if (!pathlen) goto exit; -path[pathlen] = '\\'; +// Buffer is not enough in two cases: +// 1. system directory + \ + module name +// 2. system directory even without module name. +if (pathlen + namelen + 2 > pathsize) { +pathsize = pathlen + namelen + 2; +new_path = av_realloc_array(path, pathsize, sizeof *path); +if (!new_path) +goto exit; +path = new_path; +// Query again to handle case #2. +pathlen = GetSystemDirectoryW(path, pathsize); +if (!pathlen) +goto exit; +} +path[pathlen] = L'\\'; wcscpy(path + pathlen + 1, name_w); module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); } @@ -73,15 +121,17 @@ exit: # define LOAD_LIBRARY_SEARCH_SYSTEM320x0800 #endif #if HAVE_WINRT -wchar_t *name_w = NULL; int ret; -if (utf8towchar(name, &name_w)) +if (!name_w) return NULL; ret = LoadPackagedLibrary(name_w, 0); av_free(name_w); return ret; #else -return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32); +/* filename may be be in CP_ACP */ +if (!name_w) +return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32); +return LoadLibraryExW(name_w, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32); #endif } #define dlopen(name, flags) win32_dlopen(name) -- 2.32.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 v8 4/6] fftools/cmdutils.c: Remove MAX_PATH limit and replace fopen with av_fopen_utf8
--- fftools/cmdutils.c | 38 +- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 5d7cdc3..a66dbb2 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -37,6 +37,7 @@ #include "libswresample/swresample.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" +#include "libavutil/avutil.h" #include "libavutil/channel_layout.h" #include "libavutil/display.h" #include "libavutil/mathematics.h" @@ -50,6 +51,7 @@ #include "opt_common.h" #ifdef _WIN32 #include +#include "compat/w32dlfcn.h" #endif AVDictionary *sws_dict; @@ -812,28 +814,43 @@ FILE *get_preset_file(char *filename, size_t filename_size, { FILE *f = NULL; int i; +#if HAVE_GETMODULEHANDLE && defined(_WIN32) +char *datadir = NULL; +#endif const char *base[3] = { getenv("FFMPEG_DATADIR"), getenv("HOME"), FFMPEG_DATADIR, }; if (is_path) { av_strlcpy(filename, preset_name, filename_size); -f = fopen(filename, "r"); +f = av_fopen_utf8(filename, "r"); } else { #if HAVE_GETMODULEHANDLE && defined(_WIN32) -char datadir[MAX_PATH], *ls; +wchar_t *datadir_w = get_module_filename(NULL); base[2] = NULL; -if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1)) +if (wchartoutf8(datadir_w, &datadir)) +datadir = NULL; +av_free(datadir_w); + +if (datadir) { -for (ls = datadir; ls < datadir + strlen(datadir); ls++) +char *ls; +for (ls = datadir; *ls; ls++) if (*ls == '\\') *ls = '/'; if (ls = strrchr(datadir, '/')) { -*ls = 0; -strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir)); -base[2] = datadir; +const ptrdiff_t datadir_len = ls - datadir; +const size_t desired_size = datadir_len + strlen("/ffpresets") + 1; +char *new_datadir = av_realloc_array( +datadir, desired_size, sizeof *datadir); +if (new_datadir) { +datadir = new_datadir; +datadir[datadir_len] = 0; +strncat(datadir, "/ffpresets", desired_size - 1 - datadir_len); +base[2] = datadir; +} } } #endif @@ -842,17 +859,20 @@ FILE *get_preset_file(char *filename, size_t filename_size, continue; snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", preset_name); -f = fopen(filename, "r"); +f = av_fopen_utf8(filename, "r"); if (!f && codec_name) { snprintf(filename, filename_size, "%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec_name, preset_name); -f = fopen(filename, "r"); +f = av_fopen_utf8(filename, "r"); } } } +#if HAVE_GETMODULEHANDLE && defined(_WIN32) +av_free(datadir); +#endif return f; } -- 2.32.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 v8 5/6] fftools: Enable long path support on Windows (fixes #8885)
--- fftools/Makefile | 5 + fftools/fftools.manifest | 10 ++ fftools/manifest.rc | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 fftools/fftools.manifest create mode 100644 fftools/manifest.rc diff --git a/fftools/Makefile b/fftools/Makefile index 5ebf50d..213f3f0 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -11,6 +11,11 @@ ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) OBJS-ffmpeg+= fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o +# Windows resource files +OBJS-ffmpeg-$(HAVE_GNU_WINDRES) += fftools/manifest.o +OBJS-ffplay-$(HAVE_GNU_WINDRES) += fftools/manifest.o +OBJS-ffprobe-$(HAVE_GNU_WINDRES) += fftools/manifest.o + define DOFFTOOL OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes) $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1)) diff --git a/fftools/fftools.manifest b/fftools/fftools.manifest new file mode 100644 index 000..30b7d8f --- /dev/null +++ b/fftools/fftools.manifest @@ -0,0 +1,10 @@ + + + + + +http://schemas.microsoft.com/SMI/2016/WindowsSettings";> + true + + + diff --git a/fftools/manifest.rc b/fftools/manifest.rc new file mode 100644 index 000..e436fa7 --- /dev/null +++ b/fftools/manifest.rc @@ -0,0 +1,3 @@ +#include + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "fftools.manifest" -- 2.32.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] MAINTAINERS: add Niklas Haas for vf_libplacebo.c
On Mon, Mar 28, 2022 at 10:31 PM Lynne wrote: > > 28 Mar 2022, 22:14 by jamr...@gmail.com: > > > On 3/28/2022 3:33 PM, Niklas Haas wrote: > > > >> From: Niklas Haas > >> > >> So I can merge my own changes to this filter after they pass peer > >> review, as well as keeping it in sync with upstream API changes / new > >> features. > >> > >> Signed-off-by: Niklas Haas > >> --- > >> MAINTAINERS | 2 ++ > >> 1 file changed, 2 insertions(+) > >> > >> diff --git a/MAINTAINERS b/MAINTAINERS > >> index 931cf4bd2c..76e1332ad8 100644 > >> --- a/MAINTAINERS > >> +++ b/MAINTAINERS > >> @@ -354,6 +354,7 @@ Filters: > >> vf_il.c Paul B Mahol > >> vf_(t)interlace Thomas Mundt (CC > >> ) > >> vf_lenscorrection.c Daniel Oberhoff > >> + vf_libplacebo.c Niklas Haas > >> vf_mergeplanes.c Paul B Mahol > >> vf_mestimate.cDavinder Singh > >> vf_minterpolate.c Davinder Singh > >> @@ -620,6 +621,7 @@ Loren Merritt ABD9 08F4 C920 3F65 D8BE > >> 35D7 1540 DAA7 060F 56DE > >> Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 > >> 3F03 4464 > >> Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 > >> 040B 0FAB > >> Nicolas George24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 > >> 36E5 4C93 > >> +Niklas Haas (haasn) 1DDB 8076 B14D 5B48 32FC 99D9 EB52 DA9C > >> 02BA 6FB4 > >> Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC > >> E011 13B1 > >> Panagiotis Issaris6571 13A3 33D9 3726 F728 AA98 F643 B12E > >> ECF3 E029 > >> Peter RossA907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 > >> AC40 DD6B > >> > > > > Applied. > > > > I'm not okay with this. I don't mind anyone pushing approved patches, > but I still want to review and have final say on all Vulkan code. Could you > change that? > I think haasn was more of a maintainer on the film grain stuff. He wrote this filter and maintains it, as it also interacts with his library, I don't see the problem here. The interaction with the Vulkan code in FFmpeg seems minimal, mostly just using it through the public hwcontext interface and avfilter hwframe support to read vulkan frames, which is basically public API. - Hendrik ___ 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 v8 6/6] fftools: Use UTF-8 on Windows
--- fftools/fftools.manifest | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fftools/fftools.manifest b/fftools/fftools.manifest index 30b7d8f..d1ac1e4 100644 --- a/fftools/fftools.manifest +++ b/fftools/fftools.manifest @@ -3,8 +3,10 @@ -http://schemas.microsoft.com/SMI/2016/WindowsSettings";> +http://schemas.microsoft.com/SMI/2016/WindowsSettings"; + xmlns:ws2019="http://schemas.microsoft.com/SMI/2019/WindowsSettings";> true + UTF-8 -- 2.32.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avcodec/libaomenc: Add parameter for avif single image encoding
Add a parameter to libaom-av1 encoder to enforce some of the single image constraints in the AV1 encoder. Setting this flag will limit the encoder to producing exactly one frame and the sequence header that is produced by the encoder will be conformant to the AVIF specification [1]. Part of Fixing Trac ticket #7621 [1] https://aomediacodec.github.io/av1-avif Signed-off-by:: Vignesh Venkatasubramanian --- libavcodec/libaomenc.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 7dbb6f6f39..ccd0823b97 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -100,6 +100,7 @@ typedef struct AOMEncoderContext { int enable_restoration; int usage; int tune; +int still_picture; int enable_rect_partitions; int enable_1to4_partitions; int enable_ab_partitions; @@ -747,6 +748,18 @@ static av_cold int aom_init(AVCodecContext *avctx, if (res < 0) return res; +if (ctx->still_picture) { +// Set the maximum number of frames to 1. This will let libaom set +// still_picture and reduced_still_picture_header to 1 in the Sequence +// Header as required by AVIF still images. +enccfg.g_limit = 1; +// Reduce memory usage for still images. +enccfg.g_lag_in_frames = 0; +// All frames will be key frames. +enccfg.kf_max_dist = 0; +enccfg.kf_mode = AOM_KF_DISABLED; +} + /* Construct Encoder Context */ res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags); if (res != AOM_CODEC_OK) { @@ -1291,6 +1304,7 @@ static const AVOption options[] = { { "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_PSNR}, 0, 0, VE, "tune"}, { "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 0, VE, "tune"}, FF_AV1_PROFILE_OPTS +{ "still-picture", "Encode in single frame mode (typically used for still AVIF images).", OFFSET(still_picture), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, VE }, { "enable-rect-partitions", "Enable rectangular partitions", OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, { "enable-ab-partitions", "Enable ab shape partitions", OFFSET(enable_ab_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, -- 2.35.1.1021.g381101b075-goog ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avformat/av1: Add a parameter to av1c to omit seq header
Add a parameter to omit seq header when generating the av1C atom. For now, this does not change any behavior. This will be used by a follow-up patch to add AVIF support. Signed-off-by: Vignesh Venkatasubramanian --- libavformat/av1.c | 7 +-- libavformat/av1.h | 4 +++- libavformat/matroskaenc.c | 4 ++-- libavformat/movenc.c | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libavformat/av1.c b/libavformat/av1.c index 79065d0c9f..b6eaf50627 100644 --- a/libavformat/av1.c +++ b/libavformat/av1.c @@ -395,7 +395,8 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int return is_av1c ? 0 : AVERROR_INVALIDDATA; } -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size) +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, + int write_seq_header) { AVIOContext *meta_pb; AV1SequenceParameters seq_params; @@ -485,7 +486,9 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size) flush_put_bits(&pbc); avio_write(pb, header, sizeof(header)); -avio_write(pb, seq, seq_size); +if (write_seq_header) { +avio_write(pb, seq, seq_size); +} meta_size = avio_get_dyn_buf(meta_pb, &meta); if (meta_size) diff --git a/libavformat/av1.h b/libavformat/av1.h index f57dabe986..a393fbb78f 100644 --- a/libavformat/av1.h +++ b/libavformat/av1.h @@ -96,9 +96,11 @@ int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int * @param pb pointer to the AVIOContext where the av1C box shall be written * @param buf input data buffer * @param size size in bytes of the input data buffer + * @param write_seq_header If 1, Sequence Header OBU will be written inside the + * av1C box. Otherwise, Sequence Header OBU will be omitted. * * @return >= 0 in case of success, a negative AVERROR code in case of failure */ -int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size); +int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header); #endif /* AVFORMAT_AV1_H */ diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 3b8ca11f28..d789a618a4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1089,7 +1089,7 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb, case AV_CODEC_ID_AV1: if (par->extradata_size) return ff_isom_write_av1c(dyn_cp, par->extradata, - par->extradata_size); + par->extradata_size, 1); else put_ebml_void(pb, 4 + 3); break; @@ -2665,7 +2665,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) ret = avio_open_dyn_buf(&dyn_cp); if (ret < 0) return ret; -ff_isom_write_av1c(dyn_cp, side_data, side_data_size); +ff_isom_write_av1c(dyn_cp, side_data, side_data_size, 1); codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv); if ((ret = dyn_cp->error) < 0 || !codecpriv_size && (ret = AVERROR_INVALIDDATA)) { diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 46d66c29c2..70ceb0dea4 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1306,7 +1306,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 0); ffio_wfourcc(pb, "av1C"); -ff_isom_write_av1c(pb, track->vos_data, track->vos_len); +ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1); return update_size(pb, pos); } -- 2.35.1.1021.g381101b075-goog ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing
Add an AVIF muxer by re-using the existing the mov/mp4 muxer. AVIF Specifiation: https://aomediacodec.github.io/av1-avif Sample usage for still image: ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif Sample usage for animated AVIF image: ffmpeg -i video.mp4 animated.avif We can re-use any of the AV1 encoding options that will make sense for image encoding (like bitrate, tiles, encoding speed, etc). The files generated by this muxer has been verified to be valid AVIF files by the following: 1) Displays on Chrome (both still and animated images). 2) Displays on Firefox (only still images, firefox does not support animated AVIF yet). 3) Verfied to be valid by Compliance Warden: https://github.com/gpac/ComplianceWarden Fixes the encoder/muxer part of Trac Ticket #7621 Signed-off-by: Vignesh Venkatasubramanian --- configure| 1 + libavformat/allformats.c | 1 + libavformat/movenc.c | 337 --- libavformat/movenc.h | 5 + 4 files changed, 319 insertions(+), 25 deletions(-) diff --git a/configure b/configure index e4d36aa639..b9a79d8982 100755 --- a/configure +++ b/configure @@ -3396,6 +3396,7 @@ asf_stream_muxer_select="asf_muxer" av1_demuxer_select="av1_frame_merge_bsf av1_parser" avi_demuxer_select="riffdec exif" avi_muxer_select="riffenc" +avif_muxer_select="mov_muxer" caf_demuxer_select="iso_media" caf_muxer_select="iso_media" dash_muxer_select="mp4_muxer" diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 587ad59b3c..29e58353ee 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer; extern const AVInputFormat ff_av1_demuxer; extern const AVInputFormat ff_avi_demuxer; extern const AVOutputFormat ff_avi_muxer; +extern const AVOutputFormat ff_avif_muxer; extern const AVInputFormat ff_avisynth_demuxer; extern const AVOutputFormat ff_avm2_muxer; extern const AVInputFormat ff_avr_demuxer; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 70ceb0dea4..920f3dcf25 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1306,7 +1306,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 0); ffio_wfourcc(pb, "av1C"); -ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1); +ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != MODE_AVIF); return update_size(pb, pos); } @@ -2007,12 +2007,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc) } } -/* We should only ever be called by MOV or MP4. */ -av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4); +/* We should only ever be called for MOV, MP4 and AVIF. */ +av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 || + track->mode == MODE_AVIF); avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "colr"); -if (track->mode == MODE_MP4) +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) ffio_wfourcc(pb, "nclx"); else ffio_wfourcc(pb, "nclc"); @@ -2022,7 +2023,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc) avio_wb16(pb, track->par->color_primaries); avio_wb16(pb, track->par->color_trc); avio_wb16(pb, track->par->color_space); -if (track->mode == MODE_MP4) { +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) { int full_range = track->par->color_range == AVCOL_RANGE_JPEG; avio_w8(pb, full_range << 7); } @@ -2088,7 +2089,7 @@ static void find_compressor(char * compressor_name, int len, MOVTrack *track) || (track->par->width == 1440 && track->par->height == 1080) || (track->par->width == 1920 && track->par->height == 1080); -if (track->mode == MODE_MOV && +if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) && (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) { av_strlcpy(compressor_name, encoder->value, 32); } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) { @@ -2109,6 +2110,25 @@ static void find_compressor(char * compressor_name, int len, MOVTrack *track) } } +static int mov_write_ccst_tag(AVIOContext *pb) +{ +int64_t pos = avio_tell(pb); +// Write sane defaults: +// all_ref_pics_intra = 0 : all samples can use any type of reference. +// intra_pred_used = 1 : intra prediction may or may not be used. +// max_ref_per_pic = 15 : reserved value to indicate that any number of +//reference images can be used. +uint8_t ccstValue = (0 << 7) | /* all_ref_pics_intra */ +(1 << 6) | /* intra_pred_used */ +(15 << 2); /* max_ref_per_pic */ +avio_wb32(pb, 0); /* size */ +ffio_wfourcc(pb, "ccst"); +avio_wb32(pb, 0); /* Version & f
Re: [FFmpeg-devel] [PATCH v9 4/5] avformat/image2: add Jpeg XL as image2 format
On 3/24/22 14:38, Michael Niedermayer wrote: make -j32 tools/probetest && tools/probetest 256 4096 testing size=1 testing size=2 testing size=4 Assertion n>=0 && n<=32 failed at libavcodec/get_bits.h:549 Aborted (core dumped) Not sure where this failure is coming from as I cannot reproduce it. Leo Izen (thebombzen) ___ 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] MAINTAINERS: add Niklas Haas for vf_libplacebo.c
On Mon, 28 Mar 2022 22:31:36 +0200 Lynne wrote: > I'm not okay with this. I don't mind anyone pushing approved patches, > but I still want to review and have final say on all Vulkan code. Could you > change that? The contents of vf_libplacebo is not "Vulkan code". The only thing Vulkan about it is the minimal plumbing between AVFrame and libplacebo, most of which is actually already happening inside libplacebo's codebase (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 v9 3/5] avcodec/libjxl: add Jpeg XL encoding via libjxl
On 3/23/22 11:08, Andreas Rheinhardt wrote: +temp = av_realloc(ctx->buffer, ctx->buffer_size); +if (!temp) { +av_freep(&ctx->buffer); If you free this, you will be in a scenario where ctx->buffer is NULL, yet ctx->buffer_size is > 0. This is inconsistent and might lead to crashs in JxlEncoderProcessOutput. So don't free this and only set buffer_size after the reallocation succeeded. Does it matter what ctx->buffer_size is if ctx->buffer is NULL? On 3/23/22 11:08, Andreas Rheinhardt wrote: Unnecessary: av_freep() resets ctx->buffer and resetting buffer_size is unnecessary. Here, you claim that resetting buffer_size is unnecessary but above you insist it is necessary. I'm confused here. Leo Izen (thebombzen) ___ 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 v7 4/6] fftools/cmdutils.c: Replace MAX_PATH-sized buffers with dynamically sized ones, and fopen with av_fopen_utf8
Fails to apply to current master. New version of these patches can be found at: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-March/294654.html. Please review. ___ 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 v9 1/5] avcodec/jpegxl: add Jpeg XL image codec and parser
On 3/23/22 10:45, Andreas Rheinhardt wrote: Leo Izen: + /* any other box is skipped at this point */ +AV_WB32(tag_str, tag); +av_log(avctx, AV_LOG_VERBOSE, "skipping jxl container box: %s\n", tag_str); 1. tag_str is potentially not-zero terminated. 2. If tag_str contains a \0, it might get truncated; it would be better to just report it as hex with %X or so. 3. And actually I don't think that this should be reported at all. If I change the report level to AV_LOG_DEBUG and report it as hex, does this work? +static uint64_t jpegxl_get_bits(void *avctx, JpegXLParseContext *jxlr, int bits) +{ +if (jxlr->box_size) { +if (bits > jxlr->box_size) { +int remaining = jxlr->box_size; +uint64_t ret = jpegxl_get_bits(avctx, jxlr, remaining); +/* go to the next box */ +int status = jpegxl_skip_boxes(avctx, jxlr); +if (status) +return 0; +ret |= jpegxl_get_bits(avctx, jxlr, bits - remaining) << remaining; What guarantees that there is not a sequence of boxes with a payload of 1 byte, so that a single read can span more than two boxes? And does the file format really allow to split the payload into different boxes at arbitrary positions? Nothing guarantees it. If it does, the second call to jpegxl_get_bits will recurse. Since you can only request 64 bits at once and all jxlp boxes are at least one byte of payload, this has worst-case-scenario of 8 calls for a 64 bits request. And unfortunately, it does allow the payload to be split at arbitrary positions. +*width = w, *height = h; +return 0; >Why does this pretend to be able to fail when it just can't? I was going to move the size validity check to these, but I forgot. I will do that next revision of the patch. +*poutbuf = buf + i; +*poutbuf_size = buf_size - i; > Seems like the parser is discarding some data here (if i != 0). That's the idea. It discards data that precedes the start of the frame. Is it not supposed to do this? Leo Izen (thebombzen) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/4] avcodec: add support for hevc ambient viewing environment SEI message
On Mon, Mar 28, 2022 at 04:30:49PM +0200, Michael Niedermayer wrote: > On Mon, Mar 28, 2022 at 08:41:09PM +0800, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/hevc_sei.c | 19 +++ > > libavcodec/hevc_sei.h | 8 > > libavcodec/hevcdec.c | 10 ++ > > tests/ref/fate/hevc-dv-rpu | 6 ++ > > 4 files changed, 43 insertions(+) > > > > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c > > index ec3036f..d94df4e 100644 > > --- a/libavcodec/hevc_sei.c > > +++ b/libavcodec/hevc_sei.c > > @@ -497,6 +497,23 @@ static int > > decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h, > > return 0; > > } > > > > +static int decode_ambient_viewing_env(HEVCSEIAmbientViewingEnvironment *s, > > GetBitContext *gb, int size) > > +{ > > +if (size < 8) > > +return AVERROR_INVALIDDATA; > > + > > +s->ambient_illuminance = get_bits(gb, 32); > > get_bits_long thanks, fixed it locally. > > thx > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Its not that you shouldnt use gotos but rather that you should write > readable code and code with gotos often but not always is less readable > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] MAINTAINERS: add Niklas Haas for vf_libplacebo.c
28 Mar 2022, 23:13 by ffm...@haasn.xyz: > On Mon, 28 Mar 2022 22:31:36 +0200 Lynne wrote: > >> I'm not okay with this. I don't mind anyone pushing approved patches, >> but I still want to review and have final say on all Vulkan code. Could you >> change that? >> > > The contents of vf_libplacebo is not "Vulkan code". The only thing > Vulkan about it is the minimal plumbing between AVFrame and libplacebo, > most of which is actually already happening inside libplacebo's codebase > ( Device creation's still done from the lavu-side of things. > If anything, I still want to move this filter away from being > Vulkan-exclusive in the future, which would make it even more decoupled > from your concern. > I explicitly told you that's okay when the filter first got merged, but you didn't change it back then, and I've been waiting for you to enable it. ___ 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/7] avformat/mov_chan: rename mov_get_channel_label() to better reflect its purpose
This function turns a mov channel label into a lavf native bitmask. Signed-off-by: James Almer --- libavformat/mov_chan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index f52239d347..4607540297 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -485,7 +485,7 @@ static uint64_t mov_get_channel_layout(uint32_t tag, uint32_t bitmap) return layout_map[i].layout; } -static uint32_t mov_get_channel_label(uint32_t label) +static uint32_t mov_get_channel_mask(uint32_t label) { if (label == 0) return 0; @@ -590,7 +590,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, avio_rl32(pb); // mCoordinates[2] size -= 20; if (layout_tag == 0) { -uint32_t mask_incr = mov_get_channel_label(label); +uint32_t mask_incr = mov_get_channel_mask(label); if (mask_incr == 0) { label_mask = 0; break; -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/7] avformat/mov_chan: add a few missing channel label mappings
Signed-off-by: James Almer --- libavformat/mov_chan.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index 4607540297..98773bb460 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -485,12 +485,18 @@ static uint64_t mov_get_channel_layout(uint32_t tag, uint32_t bitmap) return layout_map[i].layout; } -static uint32_t mov_get_channel_mask(uint32_t label) +static uint64_t mov_get_channel_mask(uint32_t label) { if (label == 0) return 0; if (label <= 18) return 1U << (label - 1); +if (label == 35) +return AV_CH_WIDE_LEFT; +if (label == 36) +return AV_CH_WIDE_RIGHT; +if (label == 37) +return AV_CH_LOW_FREQUENCY_2; if (label == 38) return AV_CH_STEREO_LEFT; if (label == 39) @@ -557,8 +563,8 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size) { -uint32_t layout_tag, bitmap, num_descr, label_mask; -uint64_t mask = 0; +uint32_t layout_tag, bitmap, num_descr; +uint64_t label_mask, mask = 0; int i; if (size < 12) @@ -590,7 +596,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, avio_rl32(pb); // mCoordinates[2] size -= 20; if (layout_tag == 0) { -uint32_t mask_incr = mov_get_channel_mask(label); +uint64_t mask_incr = mov_get_channel_mask(label); if (mask_incr == 0) { label_mask = 0; break; -- 2.35.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 3/7] avformat/mov_chan: use a higher log level for a debug message
Trace is too noisy and this line is useful enough to get it printed at debug level. Signed-off-by: James Almer --- libavformat/mov_chan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index 98773bb460..3c23142f35 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -574,7 +574,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, bitmap = avio_rb32(pb); num_descr = avio_rb32(pb); -av_log(s, AV_LOG_TRACE, "chan: layout=%"PRIu32" " +av_log(s, AV_LOG_DEBUG, "chan: layout=%"PRIu32" " "bitmap=%"PRIu32" num_descr=%"PRIu32"\n", layout_tag, bitmap, num_descr); -- 2.35.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 4/7] avformat/movenc: write channel descriptions when a known layout or a bitmap can't be used
Fixes part of ticket #2865 Signed-off-by: James Almer --- libavformat/mov_chan.c | 75 -- libavformat/mov_chan.h | 8 +++-- libavformat/movenc.c | 37 +++-- 3 files changed, 90 insertions(+), 30 deletions(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index 3c23142f35..4cb373d1b9 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -504,9 +504,29 @@ static uint64_t mov_get_channel_mask(uint32_t label) return 0; } -uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, - const AVChannelLayout *ch_layout, - uint32_t *bitmap) +static uint32_t mov_get_channel_label(enum AVChannel channel) +{ +if (channel < 0) +return 0; +if (channel <= AV_CHAN_TOP_BACK_RIGHT) +return channel + 1; +if (channel == AV_CHAN_WIDE_LEFT) +return 35; +if (channel == AV_CHAN_WIDE_RIGHT) +return 36; +if (channel == AV_CHAN_LOW_FREQUENCY_2) +return 37; +if (channel == AV_CHAN_STEREO_LEFT) +return 38; +if (channel == AV_CHAN_STEREO_RIGHT) +return 39; +return 0; +} + +int ff_mov_get_channel_layout_tag(const AVCodecParameters *par, + uint32_t *layout, + uint32_t *bitmap, + uint32_t **pchannel_desc) { int i, j; uint32_t tag = 0; @@ -514,7 +534,7 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, /* find the layout list for the specified codec */ for (i = 0; mov_codec_ch_layouts[i].codec_id != AV_CODEC_ID_NONE; i++) { -if (mov_codec_ch_layouts[i].codec_id == codec_id) +if (mov_codec_ch_layouts[i].codec_id == par->codec_id) break; } if (mov_codec_ch_layouts[i].codec_id != AV_CODEC_ID_NONE) @@ -525,7 +545,7 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, const struct MovChannelLayoutMap *layout_map; /* get the layout map based on the channel count */ -channels = ch_layout->nb_channels; +channels = par->ch_layout.nb_channels; if (channels > 9) channels = 0; layout_map = mov_ch_layout_map[channels]; @@ -536,8 +556,8 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, continue; for (j = 0; layout_map[j].tag != 0; j++) { if (layout_map[j].tag== layouts[i] && -(ch_layout->order == AV_CHANNEL_ORDER_NATIVE && - layout_map[j].layout == ch_layout->u.mask)) +(par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && + layout_map[j].layout == par->ch_layout.u.mask)) break; } if (layout_map[j].tag) @@ -546,18 +566,39 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, tag = layouts[i]; } -/* if no tag was found, use channel bitmap as a backup if possible */ -if (tag == 0 && av_channel_layout_check(ch_layout) && -ch_layout->order == AV_CHANNEL_ORDER_NATIVE && -ch_layout->u.mask < 0x4) { -tag = MOV_CH_LAYOUT_USE_BITMAP; -*bitmap = (uint32_t)ch_layout->u.mask; -} else -*bitmap = 0; +*layout = tag; +*bitmap = 0; +*pchannel_desc = NULL; + +/* if no tag was found, use channel bitmap or description as a backup if possible */ +if (tag == 0) { +uint32_t *channel_desc; +if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && +par->ch_layout.u.mask < 0x4) { +*layout = MOV_CH_LAYOUT_USE_BITMAP; +*bitmap = (uint32_t)par->ch_layout.u.mask; +return 0; +} else if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) +return AVERROR(ENOSYS); + +channel_desc = av_malloc_array(par->ch_layout.nb_channels, sizeof(*channel_desc)); +if (!channel_desc) +return AVERROR(ENOMEM); + +for (i = 0; i < par->ch_layout.nb_channels; i++) { +channel_desc[i] = + mov_get_channel_label(av_channel_layout_channel_from_index(&par->ch_layout, i)); + +if (channel_desc[i] == 0) { +av_free(channel_desc); +return AVERROR(ENOSYS); +} +} -/* TODO: set channel descriptions as a secondary backup */ +*pchannel_desc = channel_desc; +} -return tag; +return 0; } int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, diff --git a/libavformat/mov_chan.h b/libavformat/mov_chan.h index 9514dfa405..2815f15f07 100644 --- a/libavformat/mov_chan.h +++ b/libavformat/mov_chan.h @@ -30,6 +30,7 @@ #include "libavutil/channel_layout.h" #include "libavcodec/codec_id.h" +#include "libavcodec/codec_par.h" #include "avformat.h" /** @@ -4
[FFmpeg-devel] [PATCH 5/7] avformat/mov_chan: move the definition of MovChannelLayoutTag to the header
Signed-off-by: James Almer --- libavformat/mov_chan.c | 104 - libavformat/mov_chan.h | 104 + 2 files changed, 104 insertions(+), 104 deletions(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index 4cb373d1b9..5b757c6a8a 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -29,110 +29,6 @@ #include "libavcodec/codec_id.h" #include "mov_chan.h" -/** - * Channel Layout Tag - * This tells which channels are present in the audio stream and the order in - * which they appear. - * - * @note We're using the channel layout tag to indicate channel order - * when the value is greater than 0x1. The Apple documentation has - * some contradictions as to how this is actually supposed to be handled. - * - * Core Audio File Format Spec: - * "The high 16 bits indicates a specific ordering of the channels." - * Core Audio Data Types Reference: - * "These identifiers specify the channels included in a layout but - *do not specify a particular ordering of those channels." - */ -enum MovChannelLayoutTag { -#define MOV_CH_LAYOUT_UNKNOWN 0x -MOV_CH_LAYOUT_USE_DESCRIPTIONS = ( 0 << 16) | 0, -MOV_CH_LAYOUT_USE_BITMAP= ( 1 << 16) | 0, -MOV_CH_LAYOUT_DISCRETEINORDER = (147 << 16) | 0, -MOV_CH_LAYOUT_MONO = (100 << 16) | 1, -MOV_CH_LAYOUT_STEREO= (101 << 16) | 2, -MOV_CH_LAYOUT_STEREOHEADPHONES = (102 << 16) | 2, -MOV_CH_LAYOUT_MATRIXSTEREO = (103 << 16) | 2, -MOV_CH_LAYOUT_MIDSIDE = (104 << 16) | 2, -MOV_CH_LAYOUT_XY= (105 << 16) | 2, -MOV_CH_LAYOUT_BINAURAL = (106 << 16) | 2, -MOV_CH_LAYOUT_AMBISONIC_B_FORMAT= (107 << 16) | 4, -MOV_CH_LAYOUT_QUADRAPHONIC = (108 << 16) | 4, -MOV_CH_LAYOUT_PENTAGONAL= (109 << 16) | 5, -MOV_CH_LAYOUT_HEXAGONAL = (110 << 16) | 6, -MOV_CH_LAYOUT_OCTAGONAL = (111 << 16) | 8, -MOV_CH_LAYOUT_CUBE = (112 << 16) | 8, -MOV_CH_LAYOUT_MPEG_3_0_A= (113 << 16) | 3, -MOV_CH_LAYOUT_MPEG_3_0_B= (114 << 16) | 3, -MOV_CH_LAYOUT_MPEG_4_0_A= (115 << 16) | 4, -MOV_CH_LAYOUT_MPEG_4_0_B= (116 << 16) | 4, -MOV_CH_LAYOUT_MPEG_5_0_A= (117 << 16) | 5, -MOV_CH_LAYOUT_MPEG_5_0_B= (118 << 16) | 5, -MOV_CH_LAYOUT_MPEG_5_0_C= (119 << 16) | 5, -MOV_CH_LAYOUT_MPEG_5_0_D= (120 << 16) | 5, -MOV_CH_LAYOUT_MPEG_5_1_A= (121 << 16) | 6, -MOV_CH_LAYOUT_MPEG_5_1_B= (122 << 16) | 6, -MOV_CH_LAYOUT_MPEG_5_1_C= (123 << 16) | 6, -MOV_CH_LAYOUT_MPEG_5_1_D= (124 << 16) | 6, -MOV_CH_LAYOUT_MPEG_6_1_A= (125 << 16) | 7, -MOV_CH_LAYOUT_MPEG_7_1_A= (126 << 16) | 8, -MOV_CH_LAYOUT_MPEG_7_1_B= (127 << 16) | 8, -MOV_CH_LAYOUT_MPEG_7_1_C= (128 << 16) | 8, -MOV_CH_LAYOUT_EMAGIC_DEFAULT_7_1= (129 << 16) | 8, -MOV_CH_LAYOUT_SMPTE_DTV = (130 << 16) | 8, -MOV_CH_LAYOUT_ITU_2_1 = (131 << 16) | 3, -MOV_CH_LAYOUT_ITU_2_2 = (132 << 16) | 4, -MOV_CH_LAYOUT_DVD_4 = (133 << 16) | 3, -MOV_CH_LAYOUT_DVD_5 = (134 << 16) | 4, -MOV_CH_LAYOUT_DVD_6 = (135 << 16) | 5, -MOV_CH_LAYOUT_DVD_10= (136 << 16) | 4, -MOV_CH_LAYOUT_DVD_11= (137 << 16) | 5, -MOV_CH_LAYOUT_DVD_18= (138 << 16) | 5, -MOV_CH_LAYOUT_AUDIOUNIT_6_0 = (139 << 16) | 6, -MOV_CH_LAYOUT_AUDIOUNIT_7_0 = (140 << 16) | 7, -MOV_CH_LAYOUT_AUDIOUNIT_7_0_FRONT = (148 << 16) | 7, -MOV_CH_LAYOUT_AAC_6_0 = (141 << 16) | 6, -MOV_CH_LAYOUT_AAC_6_1 = (142 << 16) | 7, -MOV_CH_LAYOUT_AAC_7_0 = (143 << 16) | 7, -MOV_CH_LAYOUT_AAC_OCTAGONAL = (144 << 16) | 8, -MOV_CH_LAYOUT_TMH_10_2_STD = (145 << 16) | 16, -MOV_CH_LAYOUT_TMH_10_2_FULL = (146 << 16) | 21, -MOV_CH_LAYOUT_AC3_1_0_1 = (149 << 16) | 2, -MOV_CH_LAYOUT_AC3_3_0 = (150 << 16) | 3, -MOV_CH_LAYOUT_AC3_3_1 = (151 << 16) | 4, -MOV_CH_LAYOUT_AC3_3_0_1 = (152 << 16) | 4, -MOV_CH_LAYOUT_AC3_2_1_1 = (153 << 16) | 4, -MOV_CH_LAYOUT_AC3_3_1_1 = (154 << 16) | 5, -MOV_CH_LAYOUT_EAC3_6_0_A= (155 << 16) | 6, -MOV_CH_LAYOUT_EAC3_7_0_A= (156 << 16) | 7, -MOV_CH_LAYOUT_EAC3_6_1_A= (157 << 16) | 7, -MOV_CH_LAYOUT_EAC3_6_1_B= (158 << 16) | 7, -MOV_CH_LAYOUT_EAC3_6_1_C= (159 << 16) | 7, -MOV_CH_LAYOUT_EAC3_7_1_A= (
[FFmpeg-devel] [PATCH 6/7] avformat/movenc: don't use mono layout when a front center label is expected
On output streams where a multichannel stream needs to be stored as one track per channel, each track will have a channel layout describing the position of the channel they contain. For the track with front center, the mov muxer was using the mov layout "mono" instead of the label for the front center position. Since our channel layout API considers front center == mono, we need to do some heuristics. To achieve this, we make sure all audio tracks contain streams with a single channel, and only one of them is front center. In that case, we write the front center label instead of signaling mono layout. Fixes the last part of ticket #2865 Signed-off-by: James Almer --- libavformat/movenc.c | 25 + libavformat/movenc.h | 1 + 2 files changed, 26 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 263649f1da..b9956e699c 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -887,6 +887,17 @@ static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra return ret; } +if (layout_tag == MOV_CH_LAYOUT_MONO && track->mono_as_fc > 0) { +av_assert0(!channel_desc); +channel_desc = av_malloc(sizeof(*channel_desc)); +if (!channel_desc) +return AVERROR(ENOMEM); + +layout_tag = 0; +bitmap = 0; +*channel_desc = 3; // channel label "Center" +} + num_desc = layout_tag ? 0 : track->par->ch_layout.nb_channels; avio_wb32(pb, 0); // Size @@ -6970,6 +6981,20 @@ static int mov_write_header(AVFormatContext *s) if (j == i) continue; +if (stj->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && +(trackj->par->ch_layout.nb_channels != 1 || + !av_channel_layout_compare(&trackj->par->ch_layout, + &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) +) +track->mono_as_fc = -1; + +if (stj->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && +av_channel_layout_compare(&trackj->par->ch_layout, + &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO) && +trackj->par->ch_layout.nb_channels == 1 && track->mono_as_fc >= 0 +) +track->mono_as_fc++; + if (stj->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || av_channel_layout_compare(&trackj->par->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO) || diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 2ac84ed070..67d6d4fb66 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -107,6 +107,7 @@ typedef struct MOVTrack { int tag; ///< stsd fourcc AVStream*st; AVCodecParameters *par; +int mono_as_fc; int multichannel_as_mono; int vos_len; -- 2.35.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 7/7] fate: add a test for writing channel descriptions in mov
Signed-off-by: James Almer --- tests/fate/mov.mak | 11 ++- tests/ref/fate/mov-channel-description | 42 ++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/ref/fate/mov-channel-description diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index b54c009f05..5d9f183203 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -153,4 +153,13 @@ fate-mov-mp4-disposition-mpegts-remux: CMD = transcode mpegts $(TARGET_SAMPLES)/ FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MOV_FFMPEG_FFPROBE-yes) -fate-mov: $(FATE_MOV) $(FATE_MOV_FFPROBE) $(FATE_MOV_FASTSTART) $(FATE_MOV_FFMPEG_FFPROBE-yes) +FATE_MOV_FFMPEG-$(call ALLYES, FILE_PROTOCOL PIPE_PROTOCOL \ + WAV_DEMUXER PAN_FILTER PCM_S16LE_ENCODER \ + MOV_MUXER FRAMECRC_MUXER ) \ + += fate-mov-channel-description +fate-mov-channel-description: tests/data/asynth-44100-1.wav +fate-mov-channel-description: CMD = transcode wav $(TARGET_PATH)/tests/data/asynth-44100-1.wav mov "-filter_complex [0:a:0]pan=FL|c0=c0[outFL] -map [outFL] -filter_complex [0:a:0]pan=FR|c0=c1[outFR] -map [outFR] -filter_complex [0:a:0]pan=FC|c0=c2[outFC] -map [outFC] -filter_complex [0:a:0]pan=LFE|c0=c3[outLFE] -map [outLFE] -filter_complex [0:a:0]pan=BL|c0=c4[outBL] -map [outBL] -filter_complex [0:a:0]pan=BR|c0=c5[outBR] -map [outBR] -filter_complex [0:a:0]pan=DL|c0=c6[outDL] -map [outDL] -filter_complex [0:a:0]pan=DR|c0=c7[outDR] -map [outDR] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0" + +FATE_FFMPEG += $(FATE_MOV_FFMPEG-yes) + +fate-mov: $(FATE_MOV) $(FATE_MOV_FFMPEG-yes) $(FATE_MOV_FFPROBE) $(FATE_MOV_FASTSTART) $(FATE_MOV_FFMPEG_FFPROBE-yes) diff --git a/tests/ref/fate/mov-channel-description b/tests/ref/fate/mov-channel-description new file mode 100644 index 00..21b2e11406 --- /dev/null +++ b/tests/ref/fate/mov-channel-description @@ -0,0 +1,42 @@ +497848e1bc5c9dcd416124b6f739d733 *tests/data/fate/mov-channel-description.mov +4242044 tests/data/fate/mov-channel-description.mov +#tb 0: 1/44100 +#media_type 0: audio +#codec_id 0: pcm_s16le +#sample_rate 0: 44100 +#channel_layout_name 0: 1 channels (FL) +#tb 1: 1/44100 +#media_type 1: audio +#codec_id 1: pcm_s16le +#sample_rate 1: 44100 +#channel_layout_name 1: 1 channels (FR) +#tb 2: 1/44100 +#media_type 2: audio +#codec_id 2: pcm_s16le +#sample_rate 2: 44100 +#channel_layout_name 2: mono +#tb 3: 1/44100 +#media_type 3: audio +#codec_id 3: pcm_s16le +#sample_rate 3: 44100 +#channel_layout_name 3: 1 channels (LFE) +#tb 4: 1/44100 +#media_type 4: audio +#codec_id 4: pcm_s16le +#sample_rate 4: 44100 +#channel_layout_name 4: 1 channels (BL) +#tb 5: 1/44100 +#media_type 5: audio +#codec_id 5: pcm_s16le +#sample_rate 5: 44100 +#channel_layout_name 5: 1 channels (BR) +#tb 6: 1/44100 +#media_type 6: audio +#codec_id 6: pcm_s16le +#sample_rate 6: 44100 +#channel_layout_name 6: 1 channels (DL) +#tb 7: 1/44100 +#media_type 7: audio +#codec_id 7: pcm_s16le +#sample_rate 7: 44100 +#channel_layout_name 7: 1 channels (DR) -- 2.35.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] FFmpeg 5.0.1
Hi all I intend to do a 5.0.1 release from the release/5.0 branch in the next days as its high time to make a new release with all the bugfixes so if you want to backport something please do so thx -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. 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] FFmpeg 5.0.1
Hi Michael, On Tue, Mar 29, 2022 at 1:31 AM Michael Niedermayer wrote: > > Hi all > > I intend to do a 5.0.1 release from the release/5.0 branch in the next days > as its high time to make a new release with all the bugfixes > so if you want to backport something please do so Could you include the attached patch (not in master yet either) as it fixes a regression in 5.0.0? Cheers and thanks, Dee v5-0001-avdevice-dshow-fix-regression.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".
Re: [FFmpeg-devel] [PATCH] avformat/libsrt: use a larger buffer for find_info_tag
Ping. > On Aug 14, 2021, at 6:43 PM, Zhao Zhili wrote: > > The upper limit of strlen(streamid) is 512. Use a larger buffer for > future proof, for example, deal with percent-encoding. > --- > libavformat/libsrt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > index e5701625b8..a66c85d3a2 100644 > --- a/libavformat/libsrt.c > +++ b/libavformat/libsrt.c > @@ -513,7 +513,7 @@ static int libsrt_open(URLContext *h, const char *uri, > int flags) > { > SRTContext *s = h->priv_data; > const char * p; > -char buf[256]; > +char buf[1024]; > int ret = 0; > > if (srt_startup() < 0) { > -- > 2.31.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 00/22] avdevice (mostly dshow) enhancements
The dshow patches LGTM. I think I'm in favor of the realtime behavior changes as well. Cheers! On Fri, Mar 25, 2022 at 8:11 AM Diederick Niehorster wrote: > > This patch series implements a series of features, mostly enhancing the > dshow avdevice, but also adding new functionality to avformat. > This whole patchset enabled users of the FFmpeg API to fully > query and control a dshow device, making FFmpeg a nice backend for any > program that needs access to, e.g., a webcam. > > Different from v3, part of the patches has now been accepted, so only > remaining features are in this set. Importantly, as per discussion on > the list ( > https://ffmpeg.org/pipermail/ffmpeg-devel/2021-June/281513.html, see > especially https://ffmpeg.org/pipermail/ffmpeg-devel/2021-June/281586.html), > to resolve the the unholy ABI-relationship between libavdevice and > libavformat and allow easier working on the part of the avdevice API > that lives in avformat, avdevice is now locked to a specific major and minor > version of avformat. This is documented in libavdevice/avdevice.h. > > Regarding new functionality added to avformat: > Querying the capabilities of a dshow device is also possible on a > device that is already opened. I expect/guess however that it may not be > possible to achieve that for all of the avdevices, so in principle it is > important that this patchset adds the ability to create an allocated but > unopened AVFormatContext+AVInputFormat with the new function > avformat_alloc_input_context(). This is tested in the new > device_get_capabilities example. > > > Diederick Niehorster (22): > avdevice/dshow: fix regression > avdevice: lock to minor version of avformat > avformat: add control_message function to AVInputFormat > avdevice/dshow: implement control_message interface > avdevice: add control message requesting to show config dialog > avdevice/dshow: accept show config dialog control message > avdevice/dshow: add config dialog command for crossbar and tv tuner > avdevice/avdevice: Revert "Deprecate AVDevice Capabilities API" > avdevice/avdevice: clean up avdevice_capabilities_create > avdevice: capabilities API details no longer public > avutil/opt: document AVOptionRange min_value > max_value > avdevice: Add internal helpers for querying device capabilities > avdevice: change device capabilities option type > avdevice: improve capabilities' option API > avdevice/dshow: move audio format helpers > avdevice/dshow: when closing, set context fields back to zero > avdevice/dshow: implement capabilities API > avdevice/dshow: cosmetics > avformat: add avformat_alloc_input_context() > doc/examples: adding device_get_capabilities example > Makefile/examples: cosmetics > avdevice/dshow: capabilities query also works on opened device > > configure | 2 + > doc/examples/.gitignore| 1 + > doc/examples/Makefile | 47 +- > doc/examples/Makefile.example | 1 + > doc/examples/device_get_capabilities.c | 243 + > doc/indevs.texi| 34 ++ > libavdevice/avdevice.c | 177 ++- > libavdevice/avdevice.h | 111 ++--- > libavdevice/dshow.c| 662 ++--- > libavdevice/dshow_capture.h| 14 + > libavdevice/dshow_crossbar.c | 91 ++-- > libavdevice/internal.h | 66 +++ > libavdevice/utils.c| 48 ++ > libavdevice/version.h | 15 +- > libavdevice/version_major.h| 2 +- > libavformat/avformat.h | 59 ++- > libavformat/demux.c| 74 ++- > libavformat/utils.c| 5 + > libavformat/version.h | 14 +- > libavutil/avutil.h | 3 + > libavutil/macros.h | 3 + > libavutil/opt.c| 2 +- > libavutil/opt.h| 5 + > 23 files changed, 1467 insertions(+), 212 deletions(-) > create mode 100644 doc/examples/device_get_capabilities.c > > -- > 2.28.0.windows.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 1/2] avformat/mov: log the right variable
--- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 6c847de164..54a92e3486 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5023,7 +5023,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) // pts = frag_stream_info->sidx_pts; dts = frag_stream_info->sidx_pts - sc->time_offset; av_log(c->fc, AV_LOG_DEBUG, "found sidx time %"PRId64 -", using it for pts\n", pts); +", using it for dts\n", frag_stream_info->sidx_pts); } else { dts = sc->track_end - sc->time_offset; av_log(c->fc, AV_LOG_DEBUG, "found track end time %"PRId64 -- 2.31.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 2/2] avformat/movenc: sidx earliest_presentation_time is applied after editlist
Fix #8334 --- libavformat/movenc.c | 6 +- tests/ref/fate/movenc | 10 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 46d66c29c2..079fc70d4a 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4753,7 +4753,8 @@ static int mov_write_sidx_tag(AVIOContext *pb, if (track->entry) { entries = 1; -presentation_time = track->cluster[0].dts + track->cluster[0].cts; +presentation_time = track->cluster[0].dts + track->cluster[0].cts - +track->start_dts - track->start_cts; duration = track->end_pts - (track->cluster[0].dts + track->cluster[0].cts); starts_with_SAP = track->cluster[0].flags & MOV_SYNC_SAMPLE; @@ -4768,6 +4769,9 @@ static int mov_write_sidx_tag(AVIOContext *pb, if (entries <= 0) return 0; presentation_time = track->frag_info[0].time; +/* presentation_time <= 0 is handled by mov_add_tfra_entries() */ +if (presentation_time > 0) +presentation_time -= track->start_dts + track->start_cts; } avio_wb32(pb, 0); /* size */ diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index 19e4e291b8..968a3d27f2 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -101,28 +101,28 @@ write_data len 1223, time nopts, type header atom ftyp 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init write_data len 1004, time -3, type sync atom sidx write_data len 996, time 97, type sync atom sidx -5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag +69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag write_data len 148, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom ftyp 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init-discont write_data len 996, time 97, type sync atom sidx -5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag-discont +69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag-discont write_data len 110, time nopts, type trailer atom - write_data len 1247, time nopts, type header atom ftyp 80511a51d1ac9cde62337eed7176ae03 1247 delay-moov-elst-signal-init-discont-largets write_data len 996, time 27962123, type sync atom sidx -dc695d65e8a0cdafee28acd8a5ccf81a 996 delay-moov-elst-signal-second-frag-discont-largets +471fc64644a6bf4065c489fe4e04be7d 996 delay-moov-elst-signal-second-frag-discont-largets write_data len 110, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom ftyp write_data len 2572, time -33, type sync atom sidx write_data len 996, time 517, type sync atom sidx write_data len 148, time nopts, type trailer atom - -d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr +5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr write_data len 1223, time nopts, type header atom ftyp write_data len 2572, time -33, type sync atom sidx write_data len 996, time 517, type sync atom sidx write_data len 148, time nopts, type trailer atom - -d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr-noduration +5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr-noduration write_data len 1231, time nopts, type header atom ftyp write_data len 1500, time -33, type sync atom moof write_data len 1500, time nopts, type unknown atom - -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 1/4] avformat/movenc: fix assert failure in get_cluster_duration()
> On Mar 1, 2022, at 9:32 PM, zhilizhao(赵志立) wrote: > > >> On Feb 27, 2022, at 2:49 PM, Gyan Doshi wrote: >> >> >> >> On 2022-02-27 12:04 pm, "zhilizhao(赵志立)" wrote: >>> Ping. >>> On Dec 31, 2021, at 7:36 PM, Zhao Zhili wrote: When editlist is disabled, the workaournd method of shift dts to zero and increase the first sample duration doesn't work if the timestamp is larger than mp4 spec restriction (e.g., sample_delta in stts entry). Further more, it triggers get_cluster_duration() assert failure. This patch will drop large offsets between multiple tracks. --- libavformat/movenc.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0f912dd012..f5bb785b01 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5917,7 +5917,18 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) * to signal the difference in starting time without an edit list. * Thus move the timestamp for this first sample to 0, increasing * its duration instead. */ -trk->cluster[trk->entry].dts = trk->start_dts = 0; +if (pkt->dts + pkt->duration <= INT32_MAX) { +trk->cluster[trk->entry].dts = trk->start_dts = 0; +} else { +/* Impossible to write a sample duration >= UINT32_MAX. >> >> As per 14496-12 (2005), sample_delta is stored as >> >> unsigned int(32) sample_delta; >> >> The only restriction is that no delta shall be zero except the last sample, >> which means UINT32_MAX is allowed. >> INT32_MAX had been set as max allowed delta in mov.c since inception. See my >> recent changes in mov.c correcting that. >> >> Will this patch break remuxing of files with large deltas? >> Let's not clamp if the spec does not call for it. > > Since get_cluster_duration() checks dts against INT_MAX, remove > the clamp at here can still trigger abort() after. > > ``` >av_assert0(next_dts <= INT_MAX); > > ``` > > The prototype of get_cluster_duration() which returns int needs > to be fixed, and a bunch of places. > > And then we can get regression issues: movenc.c output files with > delta larger than INT32_MAX can be dangerous, which is not the > case of mov.c demuxer. > > It’s a clever trick here, by using a large sample duration to > handle start time difference between multiple tracks. Since it’s > not a standard method like editlist, I think we can turn off the > strategy safely (FFmpeg abort before the patch, so it’s already > turned off in a hard way). > > What do you think? Ping. Another idea is return error instead of abort(). > >> >> Regards, >> Gyan >> ___ >> 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 1/5] avformat/movenc: remove unused argument from get_sample_flags()
Ping for patch 1-3. > On Dec 3, 2021, at 1:06 PM, Zhao Zhili wrote: > > --- > libavformat/movenc.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index 38ff90833a..634a829f28 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -4427,7 +4427,7 @@ static int mov_write_mfhd_tag(AVIOContext *pb, > MOVMuxContext *mov) > return 0; > } > > -static uint32_t get_sample_flags(MOVTrack *track, MOVIentry *entry) > +static uint32_t get_sample_flags(MOVIentry *entry) > { > return entry->flags & MOV_SYNC_SAMPLE ? MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO : >(MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | > MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC); > @@ -4487,7 +4487,7 @@ static int mov_write_tfhd_tag(AVIOContext *pb, > MOVMuxContext *mov, > /* Set the default flags based on the second sample, if available. > * If the first sample is different, that can be signaled via a > separate field. */ > if (track->entry > 1) > -track->default_sample_flags = get_sample_flags(track, > &track->cluster[1]); > +track->default_sample_flags = > get_sample_flags(&track->cluster[1]); > else > track->default_sample_flags = > track->par->codec_type == AVMEDIA_TYPE_VIDEO ? > @@ -4512,11 +4512,11 @@ static int mov_write_trun_tag(AVIOContext *pb, > MOVMuxContext *mov, > flags |= MOV_TRUN_SAMPLE_DURATION; > if (track->cluster[i].size != track->default_size) > flags |= MOV_TRUN_SAMPLE_SIZE; > -if (i > first && get_sample_flags(track, &track->cluster[i]) != > track->default_sample_flags) > +if (i > first && get_sample_flags(&track->cluster[i]) != > track->default_sample_flags) > flags |= MOV_TRUN_SAMPLE_FLAGS; > } > if (!(flags & MOV_TRUN_SAMPLE_FLAGS) && track->entry > 0 && > - get_sample_flags(track, &track->cluster[0]) != > track->default_sample_flags) > + get_sample_flags(&track->cluster[0]) != track->default_sample_flags) > flags |= MOV_TRUN_FIRST_SAMPLE_FLAGS; > if (track->flags & MOV_TRACK_CTTS) > flags |= MOV_TRUN_SAMPLE_CTS; > @@ -4538,7 +4538,7 @@ static int mov_write_trun_tag(AVIOContext *pb, > MOVMuxContext *mov, > avio_wb32(pb, moof_size + 8 + track->data_offset + > track->cluster[first].pos); /* data offset */ > if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) > -avio_wb32(pb, get_sample_flags(track, &track->cluster[first])); > +avio_wb32(pb, get_sample_flags(&track->cluster[first])); > > for (i = first; i < end; i++) { > if (flags & MOV_TRUN_SAMPLE_DURATION) > @@ -4546,7 +4546,7 @@ static int mov_write_trun_tag(AVIOContext *pb, > MOVMuxContext *mov, > if (flags & MOV_TRUN_SAMPLE_SIZE) > avio_wb32(pb, track->cluster[i].size); > if (flags & MOV_TRUN_SAMPLE_FLAGS) > -avio_wb32(pb, get_sample_flags(track, &track->cluster[i])); > +avio_wb32(pb, get_sample_flags(&track->cluster[i])); > if (flags & MOV_TRUN_SAMPLE_CTS) > avio_wb32(pb, track->cluster[i].cts); > } > -- > 2.31.1 > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/libsrt: use a larger buffer for find_info_tag
On Tue, Mar 29, 2022 at 10:21 AM "zhilizhao(赵志立)" wrote: > > Ping. > > > On Aug 14, 2021, at 6:43 PM, Zhao Zhili wrote: > > > > The upper limit of strlen(streamid) is 512. Use a larger buffer for > > future proof, for example, deal with percent-encoding. > > --- > > libavformat/libsrt.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > > index e5701625b8..a66c85d3a2 100644 > > --- a/libavformat/libsrt.c > > +++ b/libavformat/libsrt.c > > @@ -513,7 +513,7 @@ static int libsrt_open(URLContext *h, const char *uri, > > int flags) > > { > > SRTContext *s = h->priv_data; > > const char * p; > > -char buf[256]; > > +char buf[1024]; > > int ret = 0; > > > > if (srt_startup() < 0) { > > -- > > 2.31.1 LGTM, thx ___ 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] [EXT] [PATCH v5 7/7] avcodec/v4l2_m2m_dec: setup capture queue before enqueue the first frame
> From: Andriy Gelman [mailto:andriy.gel...@gmail.com] > Sent: Saturday, March 26, 2022 11:43 PM > To: FFmpeg development discussions and patches > Cc: Ming Qian > Subject: Re: [FFmpeg-devel] [EXT] [PATCH v5 7/7] avcodec/v4l2_m2m_dec: > setup capture queue before enqueue the first frame > > Caution: EXT Email > > Hi Ming, > > On Mon, 21. Mar 07:27, Ming Qian wrote: > > Hi Andriy, > > > > What do you think of this patch? > > > > The Initialization flow defined in > linux/Documentation/userspace-api/media/v4l/dev-decoder.rst > > 1. Set the coded format on OUTPUT via VIDIOC_S_FMT(). > > 2. Allocate source (bytestream) buffers via VIDIOC_REQBUFS() on OUTPUT. > > 3. Start streaming on the OUTPUT queue via VIDIOC_STREAMON(). > > 4. This step only applies to coded formats that contain resolution > information in the stream. Continue queuing/dequeuing bytestream buffers > to/from the OUTPUT queue via VIDIOC_QBUF() and VIDIOC_DQBUF(). The > buffers will be processed and returned to the client in order, until required > metadata to configure the CAPTURE queue are found. This is indicated by the > decoder sending a V4L2_EVENT_SOURCE_CHANGE event with changes set to > V4L2_EVENT_SRC_CH_RESOLUTION. > > Note: A client capable of acquiring stream parameters from the > bytestream on its own may attempt to set the width and height of the > OUTPUT format to non-zero values matching the coded size of the stream, skip > this step and continue with the Capture Setup sequence. > > > > 5. Continue with the Capture Setup sequence. > > > > In ffmpeg's implementation, ffmpeg will set non-zero width and height > on output queue, so the step 4 should be skipped, and setup the capture > queue directly. > > So the flow should be: > > 1. Set the coded format and valid resolution on OUTPUT via VIDIOC_S_FMT(). > > 2. Allocate source (bytestream) buffers via VIDIOC_REQBUFS() on OUTPUT. > > 3. Start streaming on the OUTPUT queue via VIDIOC_STREAMON(). > > 5. Continue with the Capture Setup sequence. > > > > And this patch is just following the above flow. > > > > Ming > > The v4 version didn't work for me on odroid xu4 > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fffmpeg.o > rg%2Fpipermail%2Fffmpeg-devel%2F2022-January%2F290679.html&dat > a=04%7C01%7Cming.qian%40nxp.com%7Cca988d592253473cbac408da0f3f4 > 801%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637839061704 > 093567%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l > uMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=I80bpE70S6JI > 8A%2BaXQGq4JyxL0eBbtLN58p5SpqlA6s%3D&reserved=0 > > I haven't had time retest but don't think anything has changed. > > -- > Andriy Hi Andriy, I check the S5P MFC Video Codec driver, and indeed it requires the client enqueue the output buffer which contains the sequence header. And in vidioc_g_fmt(), driver will block and wait until the header is parsed. And indeed my patch will not work on it. But it seems don't meet the specification. For S5P MFC, the step 4 can't be skipped, and the client should wait the V4L2_EVENT_SOURCE_CHANGE event before the step 5 setting up capture queue. The ffmpeg v4l2 decoder don't skip step 4, but also doesn't wait the V4L2_EVENT_SOURCE_CHANGE event. So in current, we should make it work on more devices instead of more spec? The Initialization flow defined in linux/Documentation/userspace-api/media/v4l/dev-decoder.rst 1. Set the coded format on OUTPUT via VIDIOC_S_FMT(). 2. Allocate source (bytestream) buffers via VIDIOC_REQBUFS() on OUTPUT. 3. Start streaming on the OUTPUT queue via VIDIOC_STREAMON(). 4. This step only applies to coded formats that contain resolution information in the stream. Continue queuing/dequeuing bytestream buffers to/from the OUTPUT queue via VIDIOC_QBUF() and VIDIOC_DQBUF(). The buffers will be processed and returned to the client in order, until required metadata to configure the CAPTURE queue are found. This is indicated by the decoder sending a V4L2_EVENT_SOURCE_CHANGE event with changes set to V4L2_EVENT_SRC_CH_RESOLUTION. Note: A client capable of acquiring stream parameters from the bytestream on its own may attempt to set the width and height of the OUTPUT format to non-zero values matching the coded size of the stream, skip this step and continue with the Capture Setup sequence. 5. Continue with the Capture Setup sequence. Ming ___ 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".