[FFmpeg-cvslog] lavc/mediacodecdec_common: enable refcounting of buffers unconditionally
ffmpeg | branch: master | sfan5 | Sun Sep 18 18:26:43 2022 +0200| [954784b1209f4277fa68ad755654667afbf8addd] | committer: Anton Khirnov lavc/mediacodecdec_common: enable refcounting of buffers unconditionally This allows av_mediacodec_release_buffer to be called safely after the decoder is closed, this was already the case with delay_flush=1. Note that this causes holding onto frames to keep the decoding context alive which is generally considered to be the intended behavior. Signed-off-by: sfan5 Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=954784b1209f4277fa68ad755654667afbf8addd --- libavcodec/mediacodecdec_common.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 9fa769656c..2a605e7f5b 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -265,8 +265,7 @@ static void mediacodec_buffer_release(void *opaque, uint8_t *data) ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, 0); } -if (ctx->delay_flush) -ff_mediacodec_dec_unref(ctx); +ff_mediacodec_dec_unref(ctx); av_freep(&buffer); } @@ -321,8 +320,7 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx, buffer->ctx = s; buffer->serial = atomic_load(&s->serial); -if (s->delay_flush) -ff_mediacodec_dec_ref(s); +ff_mediacodec_dec_ref(s); buffer->index = index; buffer->pts = info->presentationTimeUs; @@ -872,7 +870,7 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, MediaCodecDecContext *s, */ int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s) { -if (!s->surface || atomic_load(&s->refcount) == 1) { +if (!s->surface || !s->delay_flush || atomic_load(&s->refcount) == 1) { int ret; /* No frames (holding a reference to the codec) are retained by the ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] doc/APIchanges: mention the addition of AV_PIX_FMT_RGB[A]F*
ffmpeg | branch: master | Anton Khirnov | Wed Sep 28 10:02:01 2022 +0200| [8bafe8a418f478d9f7d911266ae173518f12b04c] | committer: Anton Khirnov doc/APIchanges: mention the addition of AV_PIX_FMT_RGB[A]F* lavu minor bump was apparently forgotten for those, so mention them in the block adding av_chroma_location*(), which was the next lavu minor bump. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8bafe8a418f478d9f7d911266ae173518f12b04c --- doc/APIchanges | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index b0a41c9e37..a6df7a231a 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -19,8 +19,10 @@ API changes, most recent first: Use av_chroma_location_enum_to_pos() or av_chroma_location_pos_to_enum() instead. -2022-09-26 - xx - lavu 57.37.100 - pixdesc.h +2022-09-26 - xx - lavu 57.37.100 - pixdesc.h pixfmt.h Add av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum(). + Add AV_PIX_FMT_RGBF32BE, AV_PIX_FMT_RGBF32LE, AV_PIX_FMT_RGBAF32BE, + AV_PIX_FMT_RGBAF32LE. 2022-09-26 - xx - lavc 59.47.100 - avcodec.h defs.h Move the AV_EF_* and FF_COMPLIANCE_* defines from avcodec.h to defs.h. ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools: Remove unused qsv declarations
ffmpeg | branch: master | Marvin Scholz | Sat Sep 24 14:20:46 2022 +0200| [d2cf6d16652df7434e7db774c03bddd9eafed83f] | committer: Anton Khirnov fftools: Remove unused qsv declarations The code that uses these was removed in ecee3b07cde23e05bcc6b4eaa55d860b62dbd2dc Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d2cf6d16652df7434e7db774c03bddd9eafed83f --- fftools/ffmpeg.h | 4 1 file changed, 4 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ede0b2bd96..db7413adcd 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -686,9 +686,6 @@ extern int auto_conversion_filters; extern const AVIOInterruptCB int_cb; extern const OptionDef options[]; -#if CONFIG_QSV -extern char *qsv_device; -#endif extern HWDevice *filter_hw_device; extern unsigned nb_output_dumped; @@ -716,7 +713,6 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int ffmpeg_parse_options(int argc, char **argv); int videotoolbox_init(AVCodecContext *s); -int qsv_init(AVCodecContext *s); HWDevice *hw_device_get_by_name(const char *name); int hw_device_init_from_string(const char *arg, HWDevice **dev); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools: Remove unused videotoolbox_init declaration
ffmpeg | branch: master | Marvin Scholz | Sat Sep 24 14:20:47 2022 +0200| [1c8e95bd99f55f1e4ee48804a1d6392f5db613a1] | committer: Anton Khirnov fftools: Remove unused videotoolbox_init declaration The code that defined videotoolbox_init was removed in 4b54818981d2783af161c2ff670b658afbdda503 Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c8e95bd99f55f1e4ee48804a1d6392f5db613a1 --- fftools/ffmpeg.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index db7413adcd..701a211544 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -712,8 +712,6 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int ffmpeg_parse_options(int argc, char **argv); -int videotoolbox_init(AVCodecContext *s); - HWDevice *hw_device_get_by_name(const char *name); int hw_device_init_from_string(const char *arg, HWDevice **dev); void hw_device_free_all(void); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/ffmpeg: Remove unused frame_bits_per_raw_sample variable
ffmpeg | branch: master | Marvin Scholz | Wed Sep 28 12:31:25 2022 +0200| [cc484545618bca5ff893f2ffb6d5f70fa163cb61] | committer: Anton Khirnov fftools/ffmpeg: Remove unused frame_bits_per_raw_sample variable Unused since the bits_per_raw_sample was made a per-output-stream option in 425889396137451ae30288c84122e28532b71596 Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cc484545618bca5ff893f2ffb6d5f70fa163cb61 --- fftools/ffmpeg.h | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 98c1a3c157..31f9dbf3ea 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -673,7 +673,6 @@ extern int print_stats; extern int64_t stats_period; extern int qp_hist; extern int stdin_interaction; -extern int frame_bits_per_raw_sample; extern AVIOContext *progress_avio; extern float max_error_rate; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavu: add an APIchanges entry for RISC-V CPU flags
ffmpeg | branch: master | Anton Khirnov | Wed Sep 28 16:40:54 2022 +0200| [5c94b6694ac74c057bc1c2f93d15d0c709da950b] | committer: Anton Khirnov lavu: add an APIchanges entry for RISC-V CPU flags Forgotten in 0c0a3deb18. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c94b6694ac74c057bc1c2f93d15d0c709da950b --- doc/APIchanges | 5 + 1 file changed, 5 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index a6df7a231a..f32a3954a0 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,11 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-27 - 0c0a3deb18 - lavu 57.38.100 - cpu.h + Add CPU flags for RISC-V vector extensions: + AV_CPU_FLAG_RVV_I32, AV_CPU_FLAG_RVV_F32, AV_CPU_FLAG_RVV_I64, + AV_CPU_FLAG_RVV_F64 + 2022-09-26 - xx - lavc 59.48.100 - avcodec.h Deprecate avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum(). Use av_chroma_location_enum_to_pos() or av_chroma_location_pos_to_enum() ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/ffmpeg: Remove unused do_deinterlace variable
ffmpeg | branch: master | Marvin Scholz | Wed Sep 28 12:31:24 2022 +0200| [793953f44ab5cdbd6bd6d99b3b74b089ebbd3bac] | committer: Anton Khirnov fftools/ffmpeg: Remove unused do_deinterlace variable Unused since removal of the -deinterlace option in d013453caafcc44c74d4bdbaa99ee4e8f32414cb Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=793953f44ab5cdbd6bd6d99b3b74b089ebbd3bac --- fftools/ffmpeg.h | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 701a211544..98c1a3c157 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -661,7 +661,6 @@ extern enum VideoSyncMethod video_sync_method; extern float frame_drop_threshold; extern int do_benchmark; extern int do_benchmark_all; -extern int do_deinterlace; extern int do_hex_dump; extern int do_pkt_dump; extern int copy_ts; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg4audio: Move ff_copy_pce_data() to a header of its own
ffmpeg | branch: master | Andreas Rheinhardt | Sat Oct 1 19:01:03 2022 +0200| [7eed125dbbcc5c97db0d922f5f10cd7598f40e19] | committer: Andreas Rheinhardt avcodec/mpeg4audio: Move ff_copy_pce_data() to a header of its own It is only used by three of the thirty files that (potentially indirectly) include mpeg4audio.h. Twenty of these files won't have a put_bits.h inclusion any more after this patch. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7eed125dbbcc5c97db0d922f5f10cd7598f40e19 --- libavcodec/aac_adtstoasc_bsf.c | 1 + libavcodec/mpeg4audio.c | 1 - libavcodec/mpeg4audio.h | 43 - libavcodec/mpeg4audio_copy_pce.h | 69 libavformat/adtsenc.c| 1 + libavformat/latmenc.c| 1 + 6 files changed, 72 insertions(+), 44 deletions(-) diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c index d32fcc5f9d..dd5e8b2a31 100644 --- a/libavcodec/aac_adtstoasc_bsf.c +++ b/libavcodec/aac_adtstoasc_bsf.c @@ -26,6 +26,7 @@ #include "put_bits.h" #include "get_bits.h" #include "mpeg4audio.h" +#include "mpeg4audio_copy_pce.h" typedef struct AACBSFContext { int first_frame_done; diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index ed72a80f6d..e38a8c0852 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -21,7 +21,6 @@ */ #include "get_bits.h" -#include "put_bits.h" #include "mpeg4audio.h" /** diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h index c486a3ddef..a6f71cff58 100644 --- a/libavcodec/mpeg4audio.h +++ b/libavcodec/mpeg4audio.h @@ -24,10 +24,7 @@ #include -#include "libavutil/attributes.h" - #include "get_bits.h" -#include "put_bits.h" typedef struct MPEG4AudioConfig { int object_type; @@ -120,44 +117,4 @@ enum AudioObjectType { #define MAX_PCE_SIZE 320 /// 16; bits -= 16) -ff_pce_copy_bits(pb, gb, 16); -if (bits) -ff_pce_copy_bits(pb, gb, bits); -align_put_bits(pb); -align_get_bits(gb); -comment_size = ff_pce_copy_bits(pb, gb, 8); -for (; comment_size > 0; comment_size--) -ff_pce_copy_bits(pb, gb, 8); - -return put_bits_count(pb) - offset; -} - #endif /* AVCODEC_MPEG4AUDIO_H */ diff --git a/libavcodec/mpeg4audio_copy_pce.h b/libavcodec/mpeg4audio_copy_pce.h new file mode 100644 index 00..435d33731e --- /dev/null +++ b/libavcodec/mpeg4audio_copy_pce.h @@ -0,0 +1,69 @@ +/* + * MPEG-4 Audio PCE copying function + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MPEG4AUDIO_COPY_PCE_H +#define AVCODEC_MPEG4AUDIO_COPY_PCE_H + +#include "libavutil/attributes.h" + +#include "get_bits.h" +#include "put_bits.h" + +static av_always_inline unsigned int ff_pce_copy_bits(PutBitContext *pb, + GetBitContext *gb, + int bits) +{ +unsigned int el = get_bits(gb, bits); +put_bits(pb, bits, el); +return el; +} + +static inline int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb) +{ +int five_bit_ch, four_bit_ch, comment_size, bits; +int offset = put_bits_count(pb); + +ff_pce_copy_bits(pb, gb, 10); // Tag, Object Type, Frequency +five_bit_ch = ff_pce_copy_bits(pb, gb, 4); // Front +five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Side +five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Back +four_bit_ch = ff_pce_copy_bits(pb, gb, 2); // LFE +four_bit_ch += ff_pce_copy_bits(pb, gb, 3); // Data +five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Coupling +if (ff_pce_copy_bits(pb, gb, 1))// Mono Mixdown +ff_pce_copy_bits(pb, gb, 4); +if (ff_pce_copy_bits(pb, gb, 1))// Stereo Mixdown +ff_pce_copy_bits(pb, gb, 4); +if (ff_pce_copy_bits(pb, gb, 1))// Matrix Mixdown +ff_pce_copy_bits(pb, gb, 3); +for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16) +ff_pce_copy_bits(pb, gb, 16); +if (bits) +ff_pce_copy_bits(pb, gb, bits); +align_put_bits(pb); +align_get_bits(gb); +commen
[FFmpeg-cvslog] avcodec/rl2: Remove wrong check
ffmpeg | branch: master | Andreas Rheinhardt | Wed Sep 28 13:52:24 2022 +0200| [98aaaf08b39fe088dc308c951a82124ec1d3b10a] | committer: Andreas Rheinhardt avcodec/rl2: Remove wrong check This check is intended to be avoid buffer overflows, yet there are four problems with it: 1. It has an in-built off-by-one error: len == out_end - out is perfectly fine and nothing to worry about. This off-by-one error led to the pixel in the lower-right corner not being set properly for the back frame of the sample from the rl2 FATE-test. This pixel is copied to every frame which is the reason for the update to the reference file of said test. With this patch, the output of the decoder matches the output as captured from the reference decoder* (apart from the fact that said reference somehow lacks the top part of the frame (copied over from the background frame)). 2. Given that the stride of the buffer may be different from the width of the video (despite one pixel taking one byte), there is a second check lateron making the first check redundant (if one returns immediately; a simple break at the second check is not sufficient, because it only exits the inner loop). 3. The check is based around the assumption of the stride being positive (it has this in common with the other check which will be fixed in a future commit). 4. Even after fixing the off-by-one error, the check in question is still triggered by all the non-background frames in the FATE sample as well as by A1100100.RL2. In all these cases, they use len == 255 and val == 128. For videos with background frame this just means "copy from the background frame", which would be done anyway lateron.* Yet for videos without it copying it is necessary to avoid leaving uninitialized parts in the video. *: Available in https://samples.mplayerhq.hu/game-formats/voyeur-rl2/ **: Due to this, the code that copies the rest from the back frame is no longer executed for any of the samples available on the sample server. Given that these are only the files from the demo version of this game, I don't know whether this code is executed for any file in existence or not. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98aaaf08b39fe088dc308c951a82124ec1d3b10a --- libavcodec/rl2.c | 5 +- tests/ref/fate/rl2 | 216 ++--- 2 files changed, 109 insertions(+), 112 deletions(-) diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 5dedb96266..2464ad59ac 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -91,9 +91,6 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, break; } -if (len >= out_end - out) -break; - if (s->back_frame) val |= 0x80; else @@ -106,7 +103,7 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, out += stride_adj; line_end += stride; if (len >= out_end - out) - break; +return; } } } diff --git a/tests/ref/fate/rl2 b/tests/ref/fate/rl2 index 9189822503..a3c6a75d05 100644 --- a/tests/ref/fate/rl2 +++ b/tests/ref/fate/rl2 @@ -3,111 +3,111 @@ #codec_id 0: rawvideo #dimensions 0: 320x200 #sar 0: 0/1 -0, 0, 0,1, 192000, 0x7112a667 -0, 1, 1,1, 192000, 0x6936abf3 -0, 2, 2,1, 192000, 0xb1f08981 -0, 3, 3,1, 192000, 0x4ce7fece -0, 4, 4,1, 192000, 0xf04decde -0, 5, 5,1, 192000, 0x47fef74b -0, 6, 6,1, 192000, 0x99b42ac2 -0, 7, 7,1, 192000, 0x3c4c419d -0, 8, 8,1, 192000, 0x66bf5588 -0, 9, 9,1, 192000, 0xe1de4725 -0, 10, 10,1, 192000, 0x348b2af9 -0, 11, 11,1, 192000, 0x1ce73e83 -0, 12, 12,1, 192000, 0xcdaa6e02 -0, 13, 13,1, 192000, 0x370dc2ce -0, 14, 14,1, 192000, 0x1e1e40fe -0, 15, 15,1, 192000, 0x491470a4 -0, 16, 16,1, 192000, 0x88c43e9a -0, 17, 17,1, 192000, 0x036f3f44 -0, 18, 18,1, 192000, 0xc8be7e25 -0, 19, 19,1, 192000, 0xbedb397d -0, 20, 20,1, 192000, 0x97c410f4 -0, 21, 21,1, 192000, 0xc2c8225d -0, 22, 22,1, 192000, 0xe396bccb -0, 23, 23,1, 192000, 0x7e89c24c -0, 24, 24,1, 192000, 0xb044954c -0, 25, 25,1, 192000, 0x335890dd -0, 26, 26,1, 192000, 0x58a457c0 -0, 27, 27,1, 192000, 0xeb0f
[FFmpeg-cvslog] avcodec/rl2: Don't presume stride to be > 0
ffmpeg | branch: master | Andreas Rheinhardt | Wed Sep 28 15:50:53 2022 +0200| [b7848d1b2abfbd22b29fa88522e550d4f68cfc49] | committer: Andreas Rheinhardt avcodec/rl2: Don't presume stride to be > 0 Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7848d1b2abfbd22b29fa88522e550d4f68cfc49 --- libavcodec/rl2.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 2464ad59ac..467c4913a4 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -65,7 +65,7 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, int i; const uint8_t *back_frame = s->back_frame; const uint8_t *in_end = in + size; -const uint8_t *out_end= out + stride * s->avctx->height; +const uint8_t *out_end= out + stride * s->avctx->height - stride_adj; uint8_t *line_end; /** copy start of the background frame */ @@ -100,18 +100,20 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, *out++ = (val == 0x80) ? *back_frame : val; back_frame++; if (out == line_end) { +if (out == out_end) +return; out += stride_adj; line_end += stride; - if (len >= out_end - out) -return; } } } /** copy the rest from the background frame */ if (s->back_frame) { -while (out < out_end) { +while (1) { memcpy(out, back_frame, line_end - out); +if (line_end == out_end) +break; back_frame += line_end - out; out = line_end + stride_adj; line_end += stride; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/rl2: Use ptrdiff_t for stride
ffmpeg | branch: master | Andreas Rheinhardt | Wed Sep 28 15:55:18 2022 +0200| [73f104201b2c4c63f71c65bd11880c87bcb17a8a] | committer: Andreas Rheinhardt avcodec/rl2: Use ptrdiff_t for stride Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73f104201b2c4c63f71c65bd11880c87bcb17a8a --- libavcodec/rl2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 467c4913a4..76982f0426 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -57,11 +57,11 @@ typedef struct Rl2Context { * @param video_base offset of the rle data inside the frame */ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, - uint8_t *out, int stride, int video_base) + uint8_t *out, ptrdiff_t stride, int video_base) { int base_x = video_base % s->avctx->width; int base_y = video_base / s->avctx->width; -int stride_adj = stride - s->avctx->width; +ptrdiff_t stride_adj = stride - s->avctx->width; int i; const uint8_t *back_frame = s->back_frame; const uint8_t *in_end = in + size; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/rl2: Fix undefined pointer arithmetic
ffmpeg | branch: master | Andreas Rheinhardt | Wed Sep 28 17:58:00 2022 +0200| [87f243911e0769b560162bce1a356699784e1fea] | committer: Andreas Rheinhardt avcodec/rl2: Fix undefined pointer arithmetic Don't increment back_frame if it does not correspond to a real buffer. To do this, handle copying from the back frame separately from the "use coded value" codepath; also use memcpy for the former, as the chunks here are typically worth it. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=87f243911e0769b560162bce1a356699784e1fea --- libavcodec/rl2.c | 35 --- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 76982f0426..7938ef1d92 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -69,13 +69,16 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, uint8_t *line_end; /** copy start of the background frame */ +if (s->back_frame) { for (i = 0; i <= base_y; i++) { -if (s->back_frame) memcpy(out, back_frame, s->avctx->width); out+= stride; back_frame += s->avctx->width; } back_frame += base_x - s->avctx->width; +} else { +out += stride * (base_y + 1); +} line_end= out - stride_adj; out+= base_x - stride; @@ -89,16 +92,32 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, len = *in++; if (!len) break; +val &= 0x7F; } -if (s->back_frame) +if (back_frame) { +if (!val) { +do { +size_t copy = FFMIN(line_end - out, len); +memcpy(out, back_frame, copy); +out+= copy; +back_frame += copy; +len-= copy; +if (out == line_end) { +if (out == out_end) +return; +out += stride_adj; +line_end += stride; +} +} while (len > 0); +continue; +} +back_frame += len; val |= 0x80; -else -val &= ~0x80; +} while (len--) { -*out++ = (val == 0x80) ? *back_frame : val; -back_frame++; +*out++ = val; if (out == line_end) { if (out == out_end) return; @@ -164,7 +183,9 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx) back_size = avctx->extradata_size - EXTRADATA1_SIZE; if (back_size > 0) { -uint8_t *back_frame = av_mallocz(avctx->width*avctx->height); +/* The 254 are padding to ensure that pointer arithmetic stays within + * the buffer. */ +uint8_t *back_frame = av_mallocz(avctx->width * avctx->height + 254); if (!back_frame) return AVERROR(ENOMEM); rl2_rle_decode(s, avctx->extradata + EXTRADATA1_SIZE, back_size, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/rl2: Fix indentation
ffmpeg | branch: master | Andreas Rheinhardt | Wed Sep 28 18:19:18 2022 +0200| [5f02a261a2ddca7c79198869b45d35019baac819] | committer: Andreas Rheinhardt avcodec/rl2: Fix indentation Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f02a261a2ddca7c79198869b45d35019baac819 --- libavcodec/rl2.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 7938ef1d92..e427a27dce 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -62,7 +62,6 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, int base_x = video_base % s->avctx->width; int base_y = video_base / s->avctx->width; ptrdiff_t stride_adj = stride - s->avctx->width; -int i; const uint8_t *back_frame = s->back_frame; const uint8_t *in_end = in + size; const uint8_t *out_end= out + stride * s->avctx->height - stride_adj; @@ -70,12 +69,12 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, /** copy start of the background frame */ if (s->back_frame) { -for (i = 0; i <= base_y; i++) { +for (int i = 0; i <= base_y; i++) { memcpy(out, back_frame, s->avctx->width); -out+= stride; -back_frame += s->avctx->width; -} -back_frame += base_x - s->avctx->width; +out+= stride; +back_frame += s->avctx->width; +} +back_frame += base_x - s->avctx->width; } else { out += stride * (base_y + 1); } @@ -121,8 +120,8 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size, if (out == line_end) { if (out == out_end) return; - out += stride_adj; - line_end += stride; +out += stride_adj; +line_end += stride; } } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".