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
154 ret = snprintf(str, sizeof(str), "h264_metadata=crop_right=%d:crop_bottom=%d",154 ret = snprintf(str, sizeof(str), "h264_metadata=crop_right=%d:crop_bottom=%d",
155 crop_right, crop_bottom);155 crop_right, crop_bottom);
156 else if (avctx->codec_id == AV_CODEC_ID_HEVC)156 else if (avctx->codec_id == AV_CODEC_ID_HEVC)
157 ret = snprintf(str, sizeof(str), "hevc_metadata=crop_right=%d:crop_bottom=%d",157 /* Encoder can use CTU size larger than 16x16, so the real crop
158 crop_right, crop_bottom);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);
159 if (ret >= sizeof(str))163 if (ret >= sizeof(str))
160 return AVERROR_BUFFER_TOO_SMALL;164 return AVERROR_BUFFER_TOO_SMALL;
161 }165 }
@@ -235,7 +239,8 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) · 73 unmodified lines
235 // Workaround the alignment requirement of mediacodec. We can't do it239 // Workaround the alignment requirement of mediacodec. We can't do it
236 // silently for AV_PIX_FMT_MEDIACODEC.240 // silently for AV_PIX_FMT_MEDIACODEC.
237 if (avctx->pix_fmt != AV_PIX_FMT_MEDIACODEC &&241 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)) {
239 s->width = FFALIGN(avctx->width, 16);244 s->width = FFALIGN(avctx->width, 16);
240 s->height = FFALIGN(avctx->height, 16);245 s->height = FFALIGN(avctx->height, 16);
241 } else {246 } 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