Opened 5 weeks ago
Last modified 3 weeks 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)
Change History (7)
by , 5 weeks ago
Attachment: | photo-2024-11-21t13-15-34-662.png added |
---|
comment:1 by , 5 weeks ago
Keywords: | hwaccel added |
---|---|
Version: | unspecified → 7.1 |
by , 5 weeks ago
Attachment: | 0001-avcodec-mediacodecdec_common-export-correct-dimensio.patch added |
---|
comment:2 by , 5 weeks ago
Keywords: | crop hwaccel removed |
---|---|
Status: | new → open |
Version: | 7.1 → git-master |
Could you test the (Untested as i don't have the hardware for this) attached patch?
by , 5 weeks ago
comment:3 by , 5 weeks 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
comment:4 by , 3 weeks ago
Thanks James, your patch helped!
JFYI. To make everything work, I added to my code next option:
av_opt_set_int(codec_ctx, "apply_cropping", 0, 0)
PoC fix