Skip to content

Commit

Permalink
fixup! lavc/rkmppenc: add RKMPP H264 and HEVC encoder
Browse files Browse the repository at this point in the history
Update encoder input size quirks.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
  • Loading branch information
nyanmisaka committed Mar 28, 2024
1 parent 257e7eb commit ba84e56
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions libavcodec/rkmppenc.c
Expand Up @@ -550,7 +550,10 @@ static MPPEncFrame *rkmpp_submit_frame(AVCodecContext *avctx, AVFrame *frame)
const AVDRMFrameDescriptor *drm_desc;
const AVDRMLayerDescriptor *layer;
const AVDRMPlaneDescriptor *plane0;
const AVPixFmtDescriptor *pix_desc;
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(r->pix_fmt);
const int is_planar = pix_desc->flags & AV_PIX_FMT_FLAG_PLANAR;
const int is_rgb = pix_desc->flags & AV_PIX_FMT_FLAG_RGB;
const int is_yuv = !is_rgb && pix_desc->nb_components >= 2;
int hor_stride = 0, ver_stride = 0;
MppBufferInfo buf_info = { 0 };
MppFrameFormat mpp_fmt = r->mpp_fmt;
Expand Down Expand Up @@ -603,9 +606,19 @@ static MPPEncFrame *rkmpp_submit_frame(AVCodecContext *avctx, AVFrame *frame)
if (drm_desc->objects[0].fd < 0)
goto exit;

/* planar YUV quirks */
if ((r->pix_fmt == AV_PIX_FMT_YUV420P ||
r->pix_fmt == AV_PIX_FMT_YUV422P) && (drm_frame->width % 2)) {
av_log(avctx, AV_LOG_ERROR, "Unsupported width %d, not 2-aligned\n", drm_frame->width);
r->pix_fmt == AV_PIX_FMT_YUV422P ||
r->pix_fmt == AV_PIX_FMT_NV24) && (drm_frame->width % 2)) {
av_log(avctx, AV_LOG_ERROR, "Unsupported width '%d', not 2-aligned\n",
drm_frame->width);
goto exit;
}
/* packed RGB/YUV quirks */
if ((is_rgb || (is_yuv && !is_planar)) &&
(drm_frame->width % 2 || drm_frame->height % 2)) {
av_log(avctx, AV_LOG_ERROR, "Unsupported size '%dx%d', not 2-aligned\n",
drm_frame->width, drm_frame->height);
goto exit;
}

Expand Down Expand Up @@ -647,7 +660,6 @@ static MPPEncFrame *rkmpp_submit_frame(AVCodecContext *avctx, AVFrame *frame)
}
mpp_frame_set_fmt(mpp_frame, mpp_fmt);

pix_desc = av_pix_fmt_desc_get(r->pix_fmt);
if (is_afbc) {
hor_stride = plane0->pitch;
if ((ret = get_afbc_byte_stride(pix_desc, &hor_stride, 1)) < 0)
Expand Down

0 comments on commit ba84e56

Please sign in to comment.