[FFmpeg-devel] [PATCH 2/2] avformat/mvdec: handle audio sample size

Michael Niedermayer michael at niedermayer.cc
Sat Nov 27 17:35:21 EET 2021


On Fri, Nov 26, 2021 at 04:52:14PM -0500, John-Paul Stewart wrote:
> Adds support for reading audio sample size from the data instead of
> assuming all audio is 16 bits per sample.
> 
> Signed-off-by: John-Paul Stewart <jpstewart at personalprojects.net>
> ---
>  libavformat/mvdec.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
> index 8492928820..8b54a9ab04 100644
> --- a/libavformat/mvdec.c
> +++ b/libavformat/mvdec.c
> @@ -299,6 +299,8 @@ static int mv_read_header(AVFormatContext *avctx)
>      if (version == 2) {
>          uint64_t timestamp;
>          int v;
> +        uint32_t bytes_per_sample;
> +
>          avio_skip(pb, 22);
> 
>          /* allocate audio track first to prevent unnecessary seeking
> @@ -341,11 +343,21 @@ static int mv_read_header(AVFormatContext *avctx)
>          }
>          avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate);
> 
> -        avio_skip(pb, 4);
> +        bytes_per_sample = avio_rb32(pb);
> 
>          v = avio_rb32(pb);
>          if (v == AUDIO_FORMAT_SIGNED) {
> -            ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
> +            switch (bytes_per_sample) {
> +            case 1:
> +                ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
> +                break;
> +            case 2:
> +                ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
> +                break;
> +            default:
> +                avpriv_request_sample(avctx, "Audio sample size %i bytes", bytes_per_sample);
> +                break;
> +            }
>          } else {
>              avpriv_request_sample(avctx, "Audio compression (format
> %i)", v);
>          }

your MUA added a linebreak here

Applying: avformat/mvdec: handle audio sample size
error: corrupt patch at line 41


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211127/cb29ebd4/attachment.sig>


More information about the ffmpeg-devel mailing list