Opened 3 days ago

Last modified 2 days ago

#11317 open defect

Can AVCodec provide more crop information when decoding via MediaCodec?

Reported by: lanczos-algorithm Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: mediacodec
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I'm using an Android single-board computer based on Allwinner H618 to decode RTP stream and display it. When decoding a video stream using FFMPEG with HW MediaCodec, the frame parameters change from 1280x720 to 1280x736 at startup without any action on my part:

07-06 09:59:28.814  2158  2199 D SurfaceUtils: disconnecting from surface 0xee2fac08, reason setNativeWindowSizeFormatAndUsage
07-06 09:59:28.815  2158  2199 D SurfaceUtils: connecting to surface 0xee2fac08, reason setNativeWindowSizeFormatAndUsage
07-06 09:59:28.815  2158  2199 D SurfaceUtils: set up nativeWindow 0xee2fac08 for 1280x736, color 0x32315659, rotation 0, usage 0x402d00

07-06 09:59:28.876  2158  2204 D MyApp: FFmpeg: [h264_mediacodec @ 0xc7962500] Output MediaFormat changed to {crop-right=1279, color-format=842094169, slice-height=720, mime=video/raw, hdr-static-info=java.nio.HeapByteBuffer[pos=0 lim=25 cap=25], stride=1280, color-standard=1, color-transfer=3, crop-bottom=719, crop-left=0, width=1280, color-range=2, crop-top=0, height=736}
07-06 09:59:28.876  2158  2204 D MyApp: 
07-06 09:59:28.877  2158  2204 D MyApp: FFmpeg: [h264_mediacodec @ 0xc7962500] Output crop parameters top=0 bottom=719 left=0 right=1279, resulting dimensions width=1280 height=720
07-06 09:59:28.877  2158  2204 D MyApp: 

Apparently, to align the dimensions to 32 pixels. The avcodec_receive_frame writes width, height = 1280x720 to AVFrame and as a result, libraries that use AVCodec incorrectly determine the correct texture size, because in the frame itself there is no information about 736 anywhere. Without any additional workarounds I get a green line at the bottom

Attachments (3)

photo-2024-11-21t13-15-34-662.png (337.1 KB ) - added by lanczos-algorithm 3 days ago.
0001-avcodec-mediacodecdec_common-export-correct-dimensio.patch (4.2 KB ) - added by James 3 days ago.
PoC fix
MyApp.log (78.1 KB ) - added by lanczos-algorithm 2 days ago.

Download all attachments as: .zip

Change History (6)

by lanczos-algorithm, 3 days ago

comment:1 by lanczos-algorithm, 3 days ago

Keywords: hwaccel added
Version: unspecified7.1

comment:2 by James, 3 days ago

Keywords: crop hwaccel removed
Status: newopen
Version: 7.1git-master

Could you test the (Untested as i don't have the hardware for this) attached patch?

by lanczos-algorithm, 2 days ago

Attachment: MyApp.log added

comment:3 by lanczos-algorithm, 2 days ago

Thanks for the quick response, James. I'm currently working on the changes on my side and will test them, I'll let you know how it goes

Note: See TracTickets for help on using tickets.