Skip to content

Commit

Permalink
Adapt codec PrivateData following libavformat behavior change for AV1
Browse files Browse the repository at this point in the history
FFmpeg pre 5.0 used to skip the first 4 bytes,
hw codecs does not know how to manage without this.

FFmpeg sw codecs (via dav1d) is supposed to handle this,
but it does not either with our libavcodec implementation.

Fix AV1 decoding for ffmpeg 5+
  • Loading branch information
nnoury committed Dec 11, 2023
1 parent 4f39683 commit 6994e49
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Source/stream_parser_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,11 @@ serprintf("untouched (!?) vrate=%d; vscale=%d\n", video->rate, video->scale);

if( codecpar->extradata_size ) {
if( codecpar->extradata_size <= sizeof( video->extraData ) ) {
video->extraDataSize = codecpar->extradata_size;
memcpy( video->extraData, codecpar->extradata, video->extraDataSize );
// libavformat used to skip the first 4 bytes in av1 private data
// hw codecs and our implementation using libavcodec still want this
int offset = ( video->format == VIDEO_FORMAT_AV1 ) ? 4 : 0 ;
video->extraDataSize = codecpar->extradata_size - offset ;
memcpy( video->extraData, codecpar->extradata + offset , video->extraDataSize );
if( video->format == VIDEO_FORMAT_H264 && video->extraData[0] == 0x00 ) {
serprintf("FF: parse H264 SPS\n");
// for non-AVCC H264, parse the SPS/PPS here
Expand Down

0 comments on commit 6994e49

Please sign in to comment.