[FFmpeg-devel] [PATCH] avformat/hls_sample_encryption: Fix precedence
Fixes Coverity ticket #1492869. Signed-off-by: Andreas Rheinhardt --- libavformat/hls_sample_encryption.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c index 396fe97921..38795c7fb0 100644 --- a/libavformat/hls_sample_encryption.c +++ b/libavformat/hls_sample_encryption.c @@ -268,7 +268,7 @@ static int get_next_adts_frame(CodecParserContext *ctx, AudioFrame *frame) /* Find next sync word 0xFFF */ while (ctx->buf_ptr < ctx->buf_end - 1) { -if (*ctx->buf_ptr == 0xFF && *(ctx->buf_ptr + 1) & 0xF0 == 0xF0) +if (*ctx->buf_ptr == 0xFF && (*(ctx->buf_ptr + 1) & 0xF0) == 0xF0) break; ctx->buf_ptr++; } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/speexdec: Remove dead code
Fixes Coverity issue #1492840. Signed-off-by: Andreas Rheinhardt --- libavcodec/speexdec.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c index 4c50f54f27..90e95f0785 100644 --- a/libavcodec/speexdec.c +++ b/libavcodec/speexdec.c @@ -1221,7 +1221,7 @@ static int sb_decode(AVCodecContext *avctx, void *ptr_st, float low_pi_gain[NB_NB_SUBFRAMES]; float low_exc_rms[NB_NB_SUBFRAMES]; float interp_qlsp[NB_ORDER]; -int ret, wideband, dtx = 0; +int ret, wideband; float *low_innov_alias; float qlsp[NB_ORDER]; float ak[NB_ORDER]; @@ -1254,11 +1254,6 @@ static int sb_decode(AVCodecContext *avctx, void *ptr_st, /* If null mode (no transmission), just set a couple things to zero */ if (st->submodes[st->submodeID] == NULL) { -if (dtx) { -//sb_decode_lost(st, out, 1); -return 0; -} - for (int i = 0; i < st->frame_size; i++) out[st->frame_size + i] = 1e-15f; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] swscale/input: clamp rgbf32 values between 0, 1 before scaling
On Sat, Nov 6, 2021 at 10:52 PM wrote: > From: Mark Reid > > if the float pixel * 65535.0f > 2147483647.0f > lrintf may overfow and return negative values, depending on implementation. > nan and +/-inf values may also be implementation defined > > clamp the values between 0,1 before scaling, so lrintf > always works. > > values <=0.0f, -inf, nan = 0.0f > values >=1.0f, +inf = 1.0f > --- > libswscale/input.c | 12 +++- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/libswscale/input.c b/libswscale/input.c > index 336f957c8c..ea50c9de5c 100644 > --- a/libswscale/input.c > +++ b/libswscale/input.c > @@ -964,7 +964,7 @@ static av_always_inline void > planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV, > } > #undef rdpx > > -#define rdpx(src) (is_be ? av_int2float(AV_RB32(src)): > av_int2float(AV_RL32(src))) > +#define rdpx(src) (FFMIN(FFMAX(is_be ? av_int2float(AV_RB32(src)): > av_int2float(AV_RL32(src)), 0.0f), 1.0f)) > > static av_always_inline void planar_rgbf32_to_a(uint8_t *_dst, const > uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv) > { > @@ -1013,17 +1013,16 @@ static av_always_inline void > planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_s > } > } > > -#undef rdpx > - > static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t > *_src, const uint8_t *unused1, > const uint8_t *unused2, int > width, uint32_t *unused) > { > int i; > const float *src = (const float *)_src; > uint16_t *dst= (uint16_t *)_dst; > +int is_be = 0; > > for (i = 0; i < width; ++i){ > -dst[i] = av_clip_uint16(lrintf(65535.0f * src[i])); > +dst[i] = av_clip_uint16(lrintf(65535.0f * rdpx(src + i))); > } > } > > @@ -1033,12 +1032,15 @@ static av_always_inline void > grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t * > int i; > const uint32_t *src = (const uint32_t *)_src; > uint16_t *dst= (uint16_t *)_dst; > +int is_be = 1; > > for (i = 0; i < width; ++i){ > -dst[i] = av_clip_uint16(lrintf(65535.0f * > av_int2float(av_bswap32(src[i]; > +dst[i] = av_clip_uint16(lrintf(65535.0f * rdpx(src+ i))); > } > } > > +#undef rdpx > + > #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) > \ > static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const > uint8_t *src[4], \ >int w, int32_t > *rgb2yuv) \ > -- > 2.29.2 > > seem to not work on PowerPC, I see what's going on, I'll send a new patch ___ 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] configure: add initial RISC-V support
Quoting Michael Niedermayer (2021-11-02 16:32:28) > On Mon, Nov 01, 2021 at 10:02:50PM -0400, Brad Smith wrote: > > On 11/1/2021 8:31 AM, Michael Niedermayer wrote: > > > > > On Fri, Oct 29, 2021 at 04:43:16PM -0400, Brad Smith wrote: > > > > On 10/29/2021 2:39 PM, Michael Niedermayer wrote: > > > > > > > > > On Thu, Oct 28, 2021 at 06:13:30PM -0400, Brad Smith wrote: > > > > > > ping. > > > > > > > > > > > > On 8/8/2021 8:48 PM, Brad Smith wrote: > > > > > > > ping. > > > > > > > > > > > > > > On 7/25/2021 6:31 PM, Brad Smith wrote: > > > > > > > > OpenBSD only supports riscv64 but this is an attempt at adding > > > > > > > > some of the initial bits for RISC-V support. > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/configure b/configure > > > > > > > > index b3b8065188..8b5edaa01e 100755 > > > > > > > > --- a/configure > > > > > > > > +++ b/configure > > > > > will apply > > > > > > > > > > thx > > > > If possible can you please bring this back to the 4.4 branch? > > > Is this a bugfix or a added feature ? > > > normally we backport only bugfixes. > > > > > > thx > > > > Kind of a bug fix in a way. > > > > More and more OS's have or are working on RISC-V ports and will be using > > 4.4 for their FFmpeg release. > > > > I'm not pushing hard. Just asking. The diff is already in our port as it is. > > well i dont mind backporting this to releases if theres consensus that > thats what should be done. > That is other oppinions are welcome! Adding a new arch in a point release is slightly icky, but since the changes are just in the build system I don't see a major problem here. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/matroskadec: Don't unnecessarily reduce aspect ratio
Fixes ticket #9497. Signed-off-by: Andreas Rheinhardt --- Will apply later tonight unless there are objections. libavformat/matroskadec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b2c4927e43..a4bbbe954e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2806,7 +2806,7 @@ static int matroska_parse_tracks(AVFormatContext *s) &st->sample_aspect_ratio.den, st->codecpar->height * track->video.display_width * display_width_mul, st->codecpar->width * track->video.display_height * display_height_mul, - 255); + INT_MAX); } if (st->codecpar->codec_id != AV_CODEC_ID_HEVC) sti->need_parsing = AVSTREAM_PARSE_HEADERS; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/apngenc: Use UINT16_MAX instead of USHRT_MAX
The latter needn't be 16 bits. Signed-off-by: Andreas Rheinhardt --- Will apply this tonight unless there are objections. libavformat/apngenc.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c index c97c475274..767074ecf3 100644 --- a/libavformat/apngenc.c +++ b/libavformat/apngenc.c @@ -91,9 +91,9 @@ static int apng_write_header(AVFormatContext *format_context) return AVERROR(EINVAL); } -if (apng->last_delay.num > USHRT_MAX || apng->last_delay.den > USHRT_MAX) { +if (apng->last_delay.num > UINT16_MAX || apng->last_delay.den > UINT16_MAX) { av_reduce(&apng->last_delay.num, &apng->last_delay.den, - apng->last_delay.num, apng->last_delay.den, USHRT_MAX); + apng->last_delay.num, apng->last_delay.den, UINT16_MAX); av_log(format_context, AV_LOG_WARNING, "Last frame delay is too precise. Reducing to %d/%d (%f).\n", apng->last_delay.num, apng->last_delay.den, (double)apng->last_delay.num / apng->last_delay.den); @@ -191,7 +191,7 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet) if (packet) { int64_t delay_num_raw = (packet->dts - apng->prev_packet->dts) * codec_stream->time_base.num; int64_t delay_den_raw = codec_stream->time_base.den; -if (!av_reduce(&delay.num, &delay.den, delay_num_raw, delay_den_raw, USHRT_MAX) && +if (!av_reduce(&delay.num, &delay.den, delay_num_raw, delay_den_raw, UINT16_MAX) && !apng->framerate_warned) { av_log(format_context, AV_LOG_WARNING, "Frame rate is too high or specified too precisely. Unable to copy losslessly.\n"); @@ -281,9 +281,9 @@ static void apng_deinit(AVFormatContext *s) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { { "plays", "Number of times to play the output: 0 - infinite loop, 1 - no loop", OFFSET(plays), - AV_OPT_TYPE_INT, { .i64 = 1 }, 0, UINT_MAX, ENC }, + AV_OPT_TYPE_INT, { .i64 = 1 }, 0, UINT16_MAX, ENC }, { "final_delay", "Force delay after the last frame", OFFSET(last_delay), - AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, USHRT_MAX, ENC }, + AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, UINT16_MAX, ENC }, { NULL }, }; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mxf: support MCA audio information
On Fri, 5 Nov 2021, Marc-Antoine Arnaud wrote: --- libavformat/mxf.h| 1 + libavformat/mxfdec.c | 280 ++- 2 files changed, 275 insertions(+), 6 deletions(-) Could you mention in the commit description which standards/recommendations cover MCA in mxf? [...] @@ -2328,7 +2480,9 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) AVStream *st; FFStream *sti; AVTimecode tc; +enum AVAudioServiceType *ast; This declaration can be pushed down to where it is used. [...] +// Soundfield group +if (IS_KLV_KEY(mca_sub_descriptor->mca_label_dictionary_id, mxf_soundfield_group)) { +MXFSoundfieldGroupUL* group_ptr = (MXFSoundfieldGroupUL*)&mxf_soundfield_groups[0]; const MXFSoundfieldGroupUL *group_ptr = mxf_soundfield_groups; + +while (group_ptr->uid[0]) { +if (IS_KLV_KEY(group_ptr->uid, mca_sub_descriptor->mca_label_dictionary_id)) { +st->codecpar->channel_layout = group_ptr->id; +break; +} +group_ptr++; +} +} + +// Audio channel +if (IS_KLV_KEY(mca_sub_descriptor->mca_label_dictionary_id, mxf_audio_channel)) { +MXFChannelOrderingUL* channel_ordering_ptr = (MXFChannelOrderingUL*)&mxf_channel_ordering[0]; const MXFChannelOrderingUL *channel_ordering_ptr = mxf_channel_ordering; + +while (channel_ordering_ptr->uid[0]) { +if (IS_KLV_KEY(channel_ordering_ptr->uid, mca_sub_descriptor->mca_label_dictionary_id)) { You should check if current_channel < desciptor->channels here, and if not, then warn the user and break out of the loop. Otherwise current_channel can grow out of array limits. It should also be checked that channel_ordering_ptr->index < descriptor->channels, and if not, then similarly, warn the user and break out. Maybe a hard failure (returning AVERROR_INVALIDDATA) is not necessary, to allow some slightly invalid metadata? +source_track->channel_ordering[current_channel] = channel_ordering_ptr->index; + +if(channel_ordering_ptr->service_type != AV_AUDIO_SERVICE_TYPE_NB) { +uint8_t* side_data = av_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast)); +if (!side_data) +goto fail_and_free; +ast = (enum AVAudioServiceType*)side_data; +*ast = channel_ordering_ptr->service_type; +} + +current_channel += 1; +break; +} +channel_ordering_ptr++; +} +} + [...] +source_track->require_reordering = 0; +for (j = 0; j < descriptor->channels; ++j) { +if (source_track->channel_ordering[j] != j) { +source_track->require_reordering = 1; +break; +} +} If require_reordering == 1 here but either codec is not PCM or skip_audio_reordering is set then channel_layout should be reset to 0 (unknown). Maybe you should also set require_reordering to 0 in either of these cases, so further along you no longer have to check codec and skip_audio_reordering, only require_reordering. + +if (source_track->require_reordering && is_pcm(st->codecpar->codec_id)) { +current_channel = 0; +av_log(mxf->fc, AV_LOG_DEBUG, "MCA Audio mapping ("); +for(j = 0; j < descriptor->channels; ++j) { +for(int k = 0; k < descriptor->channels; ++k) { +if(source_track->channel_ordering[k] == current_channel) { +av_log(mxf->fc, AV_LOG_DEBUG, "%d -> %d", source_track->channel_ordering[k], k); +if (current_channel != descriptor->channels - 1) +av_log(mxf->fc, AV_LOG_DEBUG, ", "); +current_channel += 1; +} +} +} +av_log(mxf->fc, AV_LOG_DEBUG, ")\n"); +} [...] @@ -3920,6 +4185,9 @@ static const AVOption options[] = { { "eia608_extract", "extract eia 608 captions from s436m track", offsetof(MXFContext, eia608_extract), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, +{ "skip_audio_reordering", "skip audio reordering based on Multi-Channel Audio labelling", + offsetof(MXFContext, skip_audio_reordering), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, + AV_OPT_F
[FFmpeg-devel] [PATCH] avcodec/libx264: Use av_memdup() where appropriate
Signed-off-by: Andreas Rheinhardt --- Will apply tonight unless there are objections. libavcodec/libx264.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 0766b4a950..29546ebf06 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -985,10 +985,9 @@ static av_cold int X264_init(AVCodecContext *avctx) if (nal[i].i_type == NAL_SEI) { av_log(avctx, AV_LOG_INFO, "%s\n", nal[i].p_payload+25); x4->sei_size = nal[i].i_payload; -x4->sei = av_malloc(x4->sei_size); +x4->sei = av_memdup(nal[i].p_payload, x4->sei_size); if (!x4->sei) return AVERROR(ENOMEM); -memcpy(x4->sei, nal[i].p_payload, nal[i].i_payload); continue; } memcpy(p, nal[i].p_payload, nal[i].i_payload); -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/libx264: Use av_memdup() where appropriate
On 11/7/2021 8:33 AM, Andreas Rheinhardt wrote: Signed-off-by: Andreas Rheinhardt --- Will apply tonight unless there are objections. libavcodec/libx264.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 0766b4a950..29546ebf06 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -985,10 +985,9 @@ static av_cold int X264_init(AVCodecContext *avctx) if (nal[i].i_type == NAL_SEI) { av_log(avctx, AV_LOG_INFO, "%s\n", nal[i].p_payload+25); x4->sei_size = nal[i].i_payload; -x4->sei = av_malloc(x4->sei_size); +x4->sei = av_memdup(nal[i].p_payload, x4->sei_size); if (!x4->sei) return AVERROR(ENOMEM); -memcpy(x4->sei, nal[i].p_payload, nal[i].i_payload); continue; This loop will leak x4->sei if libx264 returns a x264_nal_t array with more than one SEI NALU. I assume x264_encoder_headers() is expected to only return one such NALU with the unregistered user data SEI containing the encode settings string, and i can see looking at the source code that currently it does as much, but it's not explicit in the documentation at all (It does not even mention that it returns a SEI NALU, only SPS/PPS), so in theory it could also at any point in the future start including global metadata like mastering display or content light and not be considered an API break. So maybe the av_malloc should be replaced with av_realloc and the memcpy kept around with an offset to merge two or more SEI NALUs if present, to be safe. Also, that av_log() line printing the payload is making the same risky assumption (And the offset is wrong, it should be 24). } memcpy(p, nal[i].p_payload, nal[i].i_payload); ___ 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: Check channels for mov_parse_stsd_audio()
Fixes: signed integer overflow: -776522110086937600 * 16 cannot be represented in type 'long' Fixes: 40563/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6644829447127040 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 8a910a3165f..8e85013a235 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2538,6 +2538,10 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) av_log(c->fc, AV_LOG_ERROR, "Invalid sample rate %d\n", st->codecpar->sample_rate); return AVERROR_INVALIDDATA; } +if (st->codecpar->channels < 0) { +av_log(c->fc, AV_LOG_ERROR, "Invalid channels %d\n", st->codecpar->channels); +return AVERROR_INVALIDDATA; +} } else if (st->codecpar->codec_type==AVMEDIA_TYPE_SUBTITLE){ mov_parse_stsd_subtitle(c, pb, st, sc, size - (avio_tell(pb) - start_pos)); -- 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] avformat/matroskadec: Don't unnecessarily reduce aspect ratio
On 11/7/2021 7:42 AM, Andreas Rheinhardt wrote: Fixes ticket #9497. Signed-off-by: Andreas Rheinhardt --- Will apply later tonight unless there are objections. libavformat/matroskadec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b2c4927e43..a4bbbe954e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2806,7 +2806,7 @@ static int matroska_parse_tracks(AVFormatContext *s) &st->sample_aspect_ratio.den, st->codecpar->height * track->video.display_width * display_width_mul, st->codecpar->width * track->video.display_height * display_height_mul, - 255); + INT_MAX); LGTM. } if (st->codecpar->codec_id != AV_CODEC_ID_HEVC) sti->need_parsing = AVSTREAM_PARSE_HEADERS; ___ 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] http: make caching of redirect url optional
On Tue, 2 Nov 2021, Eran Kornblau wrote: Hi all, The attached patch makes the default behavior of caching HTTP redirects optional. Is caching a redirected URL allowed per the HTTP spec? If not, then no caching should take place, or the caching should be optional, and not the default. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avcodec/libx264: Check for overflow if necessary
Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 0766b4a950..8711c72131 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -138,13 +138,23 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, { X264Context *x4 = ctx->priv_data; uint8_t *p; -int i, size = x4->sei_size, ret; +uint64_t size = x4->sei_size; +int i; +int ret; if (!nnal) return 0; -for (i = 0; i < nnal; i++) +for (int i = 0; i < nnal; i++) { size += nals[i].i_payload; +/* ff_get_encode_buffer() accepts an int64_t and + * so we need to make sure that no overflow happens before + * that. With 32bit ints this is automatically true. */ +#if INT_MAX > INT64_MAX / INT_MAX - 1 +if ((int64_t)size < 0) +return AVERROR(ERANGE); +#endif +} if ((ret = ff_get_encode_buffer(ctx, pkt, size, 0)) < 0) return ret; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avcodec/libx264: Remove always-false checks
Always false since this encoder was switched to encode2 and ff_alloc_packet() in 06484d0b8a7d4d1a694ba7ab277e2ec32d6558d7 and f2b20b7a8b6fcbcd8cc669f5211e4e2ed7d8e9f3. Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 8711c72131..4fe02dd11c 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -162,11 +162,7 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, p = pkt->data; /* Write the SEI as part of the first frame. */ -if (x4->sei_size > 0 && nnal > 0) { -if (x4->sei_size > size) { -av_log(ctx, AV_LOG_ERROR, "Error: nal buffer is too small\n"); -return -1; -} +if (x4->sei_size > 0) { memcpy(p, x4->sei, x4->sei_size); p += x4->sei_size; x4->sei_size = 0; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avcodec/libx264: Simplify copying packet data
x264.h: "the payloads of all output NALs are guaranteed to be sequential in memory." Therefore we can omit the loop. Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 4fe02dd11c..5f62c7b1d8 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -139,7 +139,6 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, X264Context *x4 = ctx->priv_data; uint8_t *p; uint64_t size = x4->sei_size; -int i; int ret; if (!nnal) @@ -165,14 +164,14 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, if (x4->sei_size > 0) { memcpy(p, x4->sei, x4->sei_size); p += x4->sei_size; +size -= x4->sei_size; x4->sei_size = 0; av_freep(&x4->sei); } -for (i = 0; i < nnal; i++){ -memcpy(p, nals[i].p_payload, nals[i].i_payload); -p += nals[i].i_payload; -} +/* x264 guarantees the payloads of the NALs + * to be sequential in memory. */ +memcpy(p, nals[0].p_payload, size); return 1; } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH]{WIP} avfilter: add moddif video filter
Signed-off-by: Paul B Mahol --- Allows combination of output of spatial only deinterlacers and spatio-temporal deinterlacers. Gives overall higher PSNR result. Spatial only deinterlacer output is used in case spatio-temporal one would use simple spatial interpolations. --- libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_moddif.c | 335 +++ 3 files changed, 337 insertions(+) create mode 100644 libavfilter/vf_moddif.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index aa499696d7..6fa344489f 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -349,6 +349,7 @@ OBJS-$(CONFIG_METADATA_FILTER) += f_metadata.o OBJS-$(CONFIG_MIDEQUALIZER_FILTER) += vf_midequalizer.o framesync.o OBJS-$(CONFIG_MINTERPOLATE_FILTER) += vf_minterpolate.o motion_estimation.o OBJS-$(CONFIG_MIX_FILTER)+= vf_mix.o framesync.o +OBJS-$(CONFIG_MODDIF_FILTER) += vf_moddif.o OBJS-$(CONFIG_MONOCHROME_FILTER) += vf_monochrome.o OBJS-$(CONFIG_MORPHO_FILTER) += vf_morpho.o OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 71087fbf60..88d91db3f1 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -334,6 +334,7 @@ extern const AVFilter ff_vf_metadata; extern const AVFilter ff_vf_midequalizer; extern const AVFilter ff_vf_minterpolate; extern const AVFilter ff_vf_mix; +extern const AVFilter ff_vf_moddif; extern const AVFilter ff_vf_monochrome; extern const AVFilter ff_vf_morpho; extern const AVFilter ff_vf_mpdecimate; diff --git a/libavfilter/vf_moddif.c b/libavfilter/vf_moddif.c new file mode 100644 index 00..90aaa5328d --- /dev/null +++ b/libavfilter/vf_moddif.c @@ -0,0 +1,335 @@ +/* + * Copyright (c) 2016 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/imgutils.h" +#include "libavutil/pixdesc.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" +#include "framesync.h" + +#define OFFSET(x) offsetof(ModDifContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM + +typedef struct ThreadData { +AVFrame *input, *spatial, *temporal, *output; +int parity; +} ThreadData; + +typedef struct ModDifContext { +const AVClass *class; + +int linesize[4]; +int planewidth[4], planeheight[4]; +int nb_planes; +int depth; +int parity; +int is_second; +int64_t pts; +AVFrame *prev, *cur, *next; +FFFrameSync fs; +} ModDifContext; + +#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit } + +static const AVOption moddif_options[] = { +{ "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, "parity" }, +CONST("tff", "assume top field first", 0, "parity"), +CONST("bff", "assume bottom field first", 1, "parity"), +CONST("auto", "auto detect parity",-1, "parity"), +{ NULL } +}; + +AVFILTER_DEFINE_CLASS(moddif); + +static const enum AVPixelFormat pix_fmts[] = { +AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P, +AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, +AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV420P, +AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, +AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, +AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, +AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, +AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12, +AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, +AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, +AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, +AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10, +AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA444P12, +AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_Y
Re: [FFmpeg-devel] [PATCH 3/3] avcodec/libx264: Simplify copying packet data
On 11/7/2021 11:36 AM, Andreas Rheinhardt wrote: x264.h: "the payloads of all output NALs are guaranteed to be sequential in memory." Therefore we can omit the loop. Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 4fe02dd11c..5f62c7b1d8 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -139,7 +139,6 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, X264Context *x4 = ctx->priv_data; uint8_t *p; uint64_t size = x4->sei_size; -int i; int ret; if (!nnal) @@ -165,14 +164,14 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, if (x4->sei_size > 0) { memcpy(p, x4->sei, x4->sei_size); p += x4->sei_size; +size -= x4->sei_size; x4->sei_size = 0; av_freep(&x4->sei); } -for (i = 0; i < nnal; i++){ -memcpy(p, nals[i].p_payload, nals[i].i_payload); -p += nals[i].i_payload; -} +/* x264 guarantees the payloads of the NALs + * to be sequential in memory. */ +memcpy(p, nals[0].p_payload, size); return 1; } 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] http: make caching of redirect url optional
On Sun, Nov 7, 2021 at 3:33 PM Marton Balint wrote: > > > > On Tue, 2 Nov 2021, Eran Kornblau wrote: > > > Hi all, > > > > The attached patch makes the default behavior of caching HTTP redirects > > optional. > > Is caching a redirected URL allowed per the HTTP spec? If not, then no > caching should take place, or the caching should be optional, and not the > default. > > Thanks, > Marton A 302 redirect can be cached, but it should respect caching headers in the response. If we don't do that to timeout the cache, we probably shouldn't be caching them, especially when some tasks can refer to hours-old information. - 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] avformat/demux: allow total size of packets in raw_packet_buffer to reach probesize
Previously this was hardcoded to 250 bytes, so probing of the stream codecs was always limited by this, and not probesize. Also keep track of the actual size of packets in raw_packet_buffer and not the remaining size for simplicity. Fixes ticket #5860. Signed-off-by: Marton Balint --- libavformat/demux.c| 10 +- libavformat/internal.h | 5 ++--- libavformat/options.c | 1 - libavformat/utils.c| 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 71a1a9bf03..745dc8687c 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -328,7 +328,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, if (s->pb && !si->data_offset) si->data_offset = avio_tell(s->pb); -si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; +si->raw_packet_buffer_size = 0; update_stream_avctx(s); @@ -432,7 +432,7 @@ no_packet: } } -end = si->raw_packet_buffer_remaining_size <= 0 +end = si->raw_packet_buffer_size >= s->probesize || sti->probe_packets <= 0; if (end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)) { @@ -544,13 +544,13 @@ FF_ENABLE_DEPRECATION_WARNINGS if (pktl) { AVStream *const st = s->streams[pktl->pkt.stream_index]; -if (si->raw_packet_buffer_remaining_size <= 0) +if (si->raw_packet_buffer_size >= s->probesize) if ((err = probe_codec(s, st, NULL)) < 0) return err; if (ffstream(st)->request_probe <= 0) { avpriv_packet_list_get(&si->raw_packet_buffer, &si->raw_packet_buffer_end, pkt); -si->raw_packet_buffer_remaining_size += pkt->size; +si->raw_packet_buffer_size -= pkt->size; return 0; } } @@ -631,7 +631,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return err; } pkt1 = &si->raw_packet_buffer_end->pkt; -si->raw_packet_buffer_remaining_size -= pkt1->size; +si->raw_packet_buffer_size += pkt1->size; if ((err = probe_codec(s, st, pkt1)) < 0) return err; diff --git a/libavformat/internal.h b/libavformat/internal.h index f1ae7db365..1f301dd17a 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -127,10 +127,9 @@ typedef struct FFFormatContext { */ AVPacket *pkt; /** - * Remaining size available for raw_packet_buffer, in bytes. + * Sum of the size of packets in raw_packet_buffer, in bytes. */ -#define RAW_PACKET_BUFFER_SIZE 250 -int raw_packet_buffer_remaining_size; +int raw_packet_buffer_size; /** * Offset to remap timestamps to be non-negative. diff --git a/libavformat/options.c b/libavformat/options.c index 753aa9b8dc..72c9bdcefe 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -174,7 +174,6 @@ AVFormatContext *avformat_alloc_context(void) } si->offset = AV_NOPTS_VALUE; -si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; si->shortest_end = AV_NOPTS_VALUE; return s; diff --git a/libavformat/utils.c b/libavformat/utils.c index 509c0ecdce..bbc61dccbb 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -303,7 +303,7 @@ void ff_flush_packet_queue(AVFormatContext *s) avpriv_packet_list_free(&si->packet_buffer, &si->packet_buffer_end); avpriv_packet_list_free(&si->raw_packet_buffer, &si->raw_packet_buffer_end); -si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; +si->raw_packet_buffer_size = 0; } int av_find_default_stream_index(AVFormatContext *s) -- 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 3/5] avformat/imf: Demuxer implementation
The comments have been addressed in v3 of the patch. On Sun, Oct 31, 2021 at 1:22 PM Pierre-Anthony Lemieux wrote: > > On Sun, Oct 31, 2021 at 11:45 AM James Almer wrote: > > > > On 10/31/2021 3:34 PM, Pierre-Anthony Lemieux wrote: > > >>> The functions are not static and are defined in imf_internal.h. They > > >>> are used in both libavformat/imfdec.c and the tests at > > >>> libavformat/tests/imf.c. Ok? > > >> > > >> If they are used in libavformat only it should be static. > > > AFAIK static functions are only available in the compilation unit > > > where they are defined, so if a static function (e.g. > > > `parse_imf_asset_map_from_xml_dom()`) is defined in > > > libavformat/imf_dec.c, it will not be available in > > > libavformat/tests/imf.c. > > > > > > Functions that can be used by other FFMPEG modules are declared in > > > "imf.h", whereas functions that are intended to be used only by the > > > IMF demuxer are declared in "imf_internal.h". > > > > > > For example, both "libavformat/tests/imf.c" and "libavformat/imfdec.c" > > > include "libavformat/imf_internal.h" so they can access > > > `parse_imf_asset_map_from_xml_dom()`. > > > > > > Does that work? Any alternative? > > > > Tests in the library's test folder can and usually include the actual .c > > file from the module they are testing, so making it static will work fine. > > Ok. To summarize: > > - functions used only by "imf_.c" should be static in "imf_.c, > and tests should include "imf_.c" > - any function/structure used by both "imf_.c" and "imf_.c" > should be declared in "imf.h", even if the function/structure is not > intended to be used beyond "imf_.c" and "imf_.c" > > In other words, splitting imf-related functions into "imf.h" > (functions potentially for use beyond the IMF demuxer) and > "imf_internal.h" (functions not for use beyond the IMF demuxer) is not > desirable. > > Ok? Happy either way, just want to make sure I get the next patch > version right :) > > > > > > ___ > > 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] avfilter/af_apad: do not add infinte silence for zero pad_dur or whole_dur
On Thu, 29 Jul 2021, Marton Balint wrote: Unfortunately pad_len and pad_dur behaviour was different if 0 was specified, pad_dur handled 0 duration as infinity, for pad_len, infinity was -1. Let's make the behaviour consistent by handling 0 duration for pad_dur and whole_dur as indeed 0 duration. This somewhat changes the behaviour of the filter if 0 was explicitly specified, but deprecating the old option and adding a new for the corrected behaviour seemed a bit overkill. So let's document the change instead. Ping, anybody against this? Slightly breaks compatibility. Thanks, Marton Signed-off-by: Marton Balint --- doc/filters.texi | 7 +-- libavfilter/af_apad.c | 8 libavfilter/version.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 66c0f87e47..f164f4d62d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2248,12 +2248,12 @@ with @option{pad_len}. @item pad_dur Specify the duration of samples of silence to add. See @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils} -for the accepted syntax. Used only if set to non-zero value. +for the accepted syntax. Used only if set to non-negative value. @item whole_dur Specify the minimum total duration in the output audio stream. See @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils} -for the accepted syntax. Used only if set to non-zero value. If the value is longer than +for the accepted syntax. Used only if set to non-negative value. If the value is longer than the input audio length, silence is added to the end, until the value is reached. This option is mutually exclusive with @option{pad_dur} @end table @@ -2262,6 +2262,9 @@ If neither the @option{pad_len} nor the @option{whole_len} nor @option{pad_dur} nor @option{whole_dur} option is set, the filter will add silence to the end of the input stream indefinitely. +Note that for ffmpeg 4.4 and earlier a zero @option{pad_dur} or +@option{whole_dur} also caused the filter to add silence indefinitely. + @subsection Examples @itemize diff --git a/libavfilter/af_apad.c b/libavfilter/af_apad.c index 8628c0c2e2..ff60eaa397 100644 --- a/libavfilter/af_apad.c +++ b/libavfilter/af_apad.c @@ -52,8 +52,8 @@ static const AVOption apad_options[] = { { "packet_size", "set silence packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 0, INT_MAX, A }, { "pad_len", "set number of samples of silence to add", OFFSET(pad_len), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, A }, { "whole_len", "set minimum target number of samples in the audio stream", OFFSET(whole_len), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, A }, -{ "pad_dur", "set duration of silence to add", OFFSET(pad_dur), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT64_MAX, A }, -{ "whole_dur", "set minimum target duration in the audio stream", OFFSET(whole_dur), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT64_MAX, A }, +{ "pad_dur", "set duration of silence to add", OFFSET(pad_dur), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, A }, +{ "whole_dur", "set minimum target duration in the audio stream", OFFSET(whole_dur), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, A }, { NULL } }; @@ -138,9 +138,9 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; APadContext *s = ctx->priv; -if (s->pad_dur) +if (s->pad_dur >= 0) s->pad_len = av_rescale(s->pad_dur, outlink->sample_rate, AV_TIME_BASE); -if (s->whole_dur) +if (s->whole_dur >= 0) s->whole_len = av_rescale(s->whole_dur, outlink->sample_rate, AV_TIME_BASE); s->pad_len_left = s->pad_len; diff --git a/libavfilter/version.h b/libavfilter/version.h index 75cd10dccd..85acd613a0 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 8 #define LIBAVFILTER_VERSION_MINOR 1 -#define LIBAVFILTER_VERSION_MICRO 103 +#define LIBAVFILTER_VERSION_MICRO 104 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ -- 2.26.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ 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] libavfilter: add a gblur_vulkan filter
> 9 Sept 2021, 07:44 by jianhua...@intel.com: > > > This commit adds a powerful and customizable gblur Vulkan filter, > > which provides a maximum 127x127 kernel size of Gaussian Filter. > > The size could be adjusted by requirements on quality or performance. > > > > The following command is on how to apply gblur_vulkan filter: > > > > ffmpeg -init_hw_device vulkan=vul:0 -filter_hw_device vul -i input.264 > > -vf > hwupload=extra_hw_frames=16,gblur_vulkan,hwdownload,format=yuv420p > > output.264 > > > > Signed-off-by: Wu Jianhua > > --- > > configure | 1 + > > libavfilter/Makefile | 1 + > > libavfilter/allfilters.c | 1 + > > libavfilter/vf_gblur_vulkan.c | 511 > ++ > > 4 files changed, 514 insertions(+) > > create mode 100644 libavfilter/vf_gblur_vulkan.c > > > > diff --git a/configure b/configure > > index af410a9d11..4b9a0d8e07 100755 > > --- a/configure > > +++ b/configure > > @@ -3601,6 +3601,7 @@ freezedetect_filter_select="scene_sad" > > frei0r_filter_deps="frei0r libdl" > > frei0r_src_filter_deps="frei0r libdl" > > fspp_filter_deps="gpl" > > +gblur_vulkan_filter_deps="vulkan_lib libglslang" > > histeq_filter_deps="gpl" > > hqdn3d_filter_deps="gpl" > > interlace_filter_deps="gpl" > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > > index af957a5ac0..5f74e33599 100644 > > --- a/libavfilter/Makefile > > +++ b/libavfilter/Makefile > > @@ -286,6 +286,7 @@ OBJS-$(CONFIG_FREEZEFRAMES_FILTER) += > vf_freezeframes.o > > OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o > > OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o qp_table.o > > OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o > > +OBJS-$(CONFIG_GBLUR_VULKAN_FILTER) += vf_gblur_vulkan.o > vulkan.o > > OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o > > OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o > > OBJS-$(CONFIG_GRAPHMONITOR_FILTER) += f_graphmonitor.o > > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > > index 0c6b2347c8..b5576de3af 100644 > > --- a/libavfilter/allfilters.c > > +++ b/libavfilter/allfilters.c > > @@ -271,6 +271,7 @@ extern const AVFilter ff_vf_freezeframes; > > extern const AVFilter ff_vf_frei0r; > > extern const AVFilter ff_vf_fspp; > > extern const AVFilter ff_vf_gblur; > > +extern const AVFilter ff_vf_gblur_vulkan; > > extern const AVFilter ff_vf_geq; > > extern const AVFilter ff_vf_gradfun; > > extern const AVFilter ff_vf_graphmonitor; > > diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c > > new file mode 100644 > > index 00..5c072f8971 > > --- /dev/null > > +++ b/libavfilter/vf_gblur_vulkan.c > > @@ -0,0 +1,511 @@ > > +/* > > + * copyright (c) 2021 Wu Jianhua > > + * This file is part of FFmpeg. > > + * > > + * FFmpeg is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * FFmpeg is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General Public > > + * License along with FFmpeg; if not, write to the Free Software > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > > + */ > > + > > +#include "libavutil/random_seed.h" > > +#include "libavutil/opt.h" > > +#include "vulkan.h" > > +#include "internal.h" > > + > > +#define CGS 32 > > +#define GBLUR_MAX_KERNEL_SIZE 127 > > + > > +typedef struct GBlurVulkanContext { > > +VulkanFilterContext vkctx; > > +FFVkExecContext *exec; > > +VulkanPipeline *pl_hor; > > +VulkanPipeline *pl_ver; > > +FFVkBuffer params_buf_hor; > > +FFVkBuffer params_buf_ver; > > + > > +VkDescriptorImageInfo input_images[3]; > > +VkDescriptorImageInfo tmp_images[3]; > > +VkDescriptorImageInfo output_images[3]; > > +VkDescriptorBufferInfo params_desc_hor; > > +VkDescriptorBufferInfo params_desc_ver; > > + > > +int initialized; > > +int size; > > +int planes; > > +int kernel_size; > > +float sigma; > > +float sigmaV; > > +AVFrame *tmpframe; > > +} GBlurVulkanContext; > > + > > +static const char gblur_horizontal[] = { > > +C(0, void gblur(const ivec2 pos, const int index) > > ) > > +C(0, { > > ) > > +C(1, vec4 sum = texture(input_image[index], pos) * > kernel[0]; ) > > +C(0, >
Re: [FFmpeg-devel] [PATCH] avformat/hls_sample_encryption: Fix precedence
Andreas Rheinhardt 于2021年11月7日周日 下午3:57写道: > > Fixes Coverity ticket #1492869. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/hls_sample_encryption.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/hls_sample_encryption.c > b/libavformat/hls_sample_encryption.c > index 396fe97921..38795c7fb0 100644 > --- a/libavformat/hls_sample_encryption.c > +++ b/libavformat/hls_sample_encryption.c > @@ -268,7 +268,7 @@ static int get_next_adts_frame(CodecParserContext *ctx, > AudioFrame *frame) > > /* Find next sync word 0xFFF */ > while (ctx->buf_ptr < ctx->buf_end - 1) { > -if (*ctx->buf_ptr == 0xFF && *(ctx->buf_ptr + 1) & 0xF0 == 0xF0) > +if (*ctx->buf_ptr == 0xFF && (*(ctx->buf_ptr + 1) & 0xF0) == 0xF0) > break; > ctx->buf_ptr++; > } > -- > 2.30.2 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". LGTM Thanks Steven ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/2] swscale/input: clamp rgbf32 values between 0, 1 before scaling
From: Mark Reid if the float pixel * 65535.0f > 2147483647.0f lrintf may overfow and return negative values, depending on implementation. nan and +/-inf values may also be implementation defined clamp the values between 0,1 before scaling, so lrintf always works. values <=0.0f, -inf, nan = 0.0f values >=1.0f, +inf = 1.0f --- libswscale/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/input.c b/libswscale/input.c index 90efdd2ffc..fc8242a758 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -964,7 +964,7 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV, } #undef rdpx -#define rdpx(src) (is_be ? av_int2float(AV_RB32(src)): av_int2float(AV_RL32(src))) +#define rdpx(src) (FFMIN(FFMAX(is_be ? av_int2float(AV_RB32(src)): av_int2float(AV_RL32(src)), 0.0f), 1.0f)) static av_always_inline void planar_rgbf32_to_a(uint8_t *_dst, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv) { -- 2.31.1.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] [PATCH v2 1/2] swscale/input: unify grayf32 funcs with rgbf32 funcs
From: Mark Reid --- libswscale/input.c | 36 +++- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/libswscale/input.c b/libswscale/input.c index 336f957c8c..90efdd2ffc 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -1013,31 +1013,19 @@ static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_s } } -#undef rdpx - static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, -const uint8_t *unused2, int width, uint32_t *unused) +const uint8_t *unused2, int width, int is_be, uint32_t *unused) { int i; const float *src = (const float *)_src; uint16_t *dst= (uint16_t *)_dst; for (i = 0; i < width; ++i){ -dst[i] = av_clip_uint16(lrintf(65535.0f * src[i])); +dst[i] = av_clip_uint16(lrintf(65535.0f * rdpx(src + i))); } } -static av_always_inline void grayf32ToY16_bswap_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, - const uint8_t *unused2, int width, uint32_t *unused) -{ -int i; -const uint32_t *src = (const uint32_t *)_src; -uint16_t *dst= (uint16_t *)_dst; - -for (i = 0; i < width; ++i){ -dst[i] = av_clip_uint16(lrintf(65535.0f * av_int2float(av_bswap32(src[i]; -} -} +#undef rdpx #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \ static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \ @@ -1092,6 +1080,12 @@ static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4 int w, int32_t *rgb2yuv) \ { \ planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \ +} \ +static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused1, const uint8_t *unused2, \ + int width, uint32_t *unused) \ +{ \ +grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \ } rgbf32_planar_funcs_endian(le, 0) @@ -1699,18 +1693,10 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->lumToYV12 = p010BEToY_c; break; case AV_PIX_FMT_GRAYF32LE: -#if HAVE_BIGENDIAN -c->lumToYV12 = grayf32ToY16_bswap_c; -#else -c->lumToYV12 = grayf32ToY16_c; -#endif +c->lumToYV12 = grayf32leToY16_c; break; case AV_PIX_FMT_GRAYF32BE: -#if HAVE_BIGENDIAN -c->lumToYV12 = grayf32ToY16_c; -#else -c->lumToYV12 = grayf32ToY16_bswap_c; -#endif +c->lumToYV12 = grayf32beToY16_c; break; case AV_PIX_FMT_Y210LE: c->lumToYV12 = y210le_Y_c; -- 2.31.1.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".
Re: [FFmpeg-devel] [PATCH] http: make caching of redirect url optional
> > On Tue, 2 Nov 2021, Eran Kornblau wrote: > > > Hi all, > > > > The attached patch makes the default behavior of caching HTTP redirects > > optional. > > Is caching a redirected URL allowed per the HTTP spec? If not, then no > caching should take place, or the caching should be optional, and not the > default. > >From a quick search on this, it seems that browsers by default cache 301 >redirects, while 302/307 are not cached by default. However, in both cases, the browser is expected to honor any Cache-Control/Expires headers. Changing the implementation to imitate the behavior of a browser would be more complex, since currently there is only a single "slot" in the cache. For example, if we have a chain of redirects 307->301->200, and we want to cache the 301 but not the 307, we can't really do it. Solving this one would require a more complex data structure, and if we add expiration/TTL to the mix, it becomes even more complex... Assuming we don't want to add a large chunk of code to handle this, the options I see are - 1. A simple boolean option - as proposed in this patch. We can argue about what the default should be :) but it felt safer to me to have the default behavior as it was before. 2. Cache only 301's directly linked to the original URL - e.g. if we have 301->301->307->301->200, we cache only the first 2 redirects. My concern here is that this would break/slow down applications that rely on the existing behavior of caching any redirect. Any thoughts/suggestions are welcome, Thank you, Eran > Thanks, > Marton > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets
Hi, Attached patch implement muxing SCTE-35 and EPG packets into mpegts stream. -- Maksym Veremeyenko From dc1b87f5e34c688bb3691767f8026a2815aab03e Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Mon, 8 Nov 2021 08:10:59 +0200 Subject: [PATCH] avformat/mpegtsenc: Implement muxing SCTE-35 and EPG packets --- libavformat/mpegtsenc.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index e3fba54..1fe3f55 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -429,6 +429,12 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st) stream_type = STREAM_TYPE_PRIVATE_DATA; } break; +case AV_CODEC_ID_SCTE_35: +stream_type = 0x86; +break; +case AV_CODEC_ID_EPG: +stream_type = 0; +break; default: av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning, "Stream %d, codec %s, is muxed as a private data stream " @@ -514,6 +520,16 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) *q++ = 0xfc;// private_data_byte } +/* put scte-35 registration tag */ +for (i = 0; i < s->nb_streams; i++) { +AVStream *st = s->streams[i]; + +if (st->codecpar->codec_id == AV_CODEC_ID_SCTE_35) { +put_registration_descriptor(&q, MKTAG('C', 'U', 'E', 'I')); +break; +} +} + val = 0xf000 | (q - program_info_length_ptr - 2); program_info_length_ptr[0] = val >> 8; program_info_length_ptr[1] = val; @@ -547,6 +563,9 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) stream_type = ts->m2ts_mode ? get_m2ts_stream_type(s, st) : get_dvb_stream_type(s, st); +if (!stream_type) +continue; + *q++ = stream_type; put16(&q, 0xe000 | ts_st->pid); desc_length_ptr = q; @@ -2099,6 +2118,34 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) ts_st->dvb_ac3_desc = dvb_ac3_desc; } av_free(hdr); +} else if (st->codecpar->codec_id == AV_CODEC_ID_SCTE_35) { +MpegTSSection sec; + +sec.pid = ts_st->pid; +sec.cc = ts_st->payload_size; +sec.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT; +sec.write_packet = section_write_packet; +sec.opaque = s; + +mpegts_write_section(&sec, pkt->data, pkt->size); + +ts_st->payload_size = sec.cc; + +return 0; +} else if (st->codecpar->codec_id == AV_CODEC_ID_EPG) { +MpegTSSection sec; + +sec.pid = EIT_PID; +sec.cc = ts_st->payload_size; +sec.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT; +sec.write_packet = section_write_packet; +sec.opaque = s; + +mpegts_write_section(&sec, pkt->data, pkt->size); + +ts_st->payload_size = sec.cc; + +return 0; } if (ts_st->payload_size && (ts_st->payload_size + size > ts->pes_payload_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".