History

avcodec/mediacodecenc: workaround the alignment requirement for H.265

Zhao Zhili committed 2 years ago

Commit 7d46ab91 parent 2a68b2d1 file · +8 −3Browse files

Unified · Split

libavcodec/mediacodecenc.c+8−3
@@ -154,8 +154,12 @@ static int mediacodec_init_bsf(AVCodecContext *avctx) · 153 unmodified lines
154154 ret = snprintf(str, sizeof(str), "h264_metadata=crop_right=%d:crop_bottom=%d",
155155 crop_right, crop_bottom);
156156 else if (avctx->codec_id == AV_CODEC_ID_HEVC)
157− ret = snprintf(str, sizeof(str), "hevc_metadata=crop_right=%d:crop_bottom=%d",
158− crop_right, crop_bottom);
157+ /* Encoder can use CTU size larger than 16x16, so the real crop
158+ * margin can be larger than crop_right/crop_bottom. Let bsf figure
159+ * out the real crop margin.
160+ */
161+ ret = snprintf(str, sizeof(str), "hevc_metadata=width=%d:height=%d",
162+ avctx->width, avctx->height);
159163 if (ret >= sizeof(str))
160164 return AVERROR_BUFFER_TOO_SMALL;
161165 }
@@ -235,7 +239,8 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) · 73 unmodified lines
235239 // Workaround the alignment requirement of mediacodec. We can't do it
236240 // silently for AV_PIX_FMT_MEDIACODEC.
237241 if (avctx->pix_fmt != AV_PIX_FMT_MEDIACODEC &&
238− avctx->codec_id == AV_CODEC_ID_H264) {
242+ (avctx->codec_id == AV_CODEC_ID_H264 ||
243+ avctx->codec_id == AV_CODEC_ID_HEVC)) {
239244 s->width = FFALIGN(avctx->width, 16);
240245 s->height = FFALIGN(avctx->height, 16);
241246 } else {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t