mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-10 01:20:31 +00:00
avcodec/lcevcdec: avoid copying the input frame
Based on the lcevc filter implementation.
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit b392d75cf7)
This commit is contained in:
parent
4007d2a532
commit
044ca5f5ef
1 changed files with 7 additions and 30 deletions
|
|
@ -47,10 +47,7 @@ static int alloc_base_frame(void *logctx, FFLCEVCContext *lcevc,
|
|||
{
|
||||
LCEVC_PictureDesc desc;
|
||||
LCEVC_ColorFormat fmt = map_format(frame->format);
|
||||
LCEVC_PictureLockHandle lock;
|
||||
uint8_t *data[4] = { NULL };
|
||||
int linesizes[4] = { 0 };
|
||||
uint32_t planes;
|
||||
LCEVC_PicturePlaneDesc planes[AV_VIDEO_MAX_PLANES] = { 0 };
|
||||
LCEVC_ReturnCode res;
|
||||
|
||||
res = LCEVC_DefaultPictureDesc(&desc, fmt, frame->width, frame->height);
|
||||
|
|
@ -64,36 +61,16 @@ static int alloc_base_frame(void *logctx, FFLCEVCContext *lcevc,
|
|||
desc.sampleAspectRatioNum = frame->sample_aspect_ratio.num;
|
||||
desc.sampleAspectRatioDen = frame->sample_aspect_ratio.den;
|
||||
|
||||
for (int i = 0; i < AV_VIDEO_MAX_PLANES; i++) {
|
||||
planes[i].firstSample = frame->data[i];
|
||||
planes[i].rowByteStride = frame->linesize[i];
|
||||
}
|
||||
|
||||
/* Allocate LCEVC Picture */
|
||||
res = LCEVC_AllocPicture(lcevc->decoder, &desc, picture);
|
||||
res = LCEVC_AllocPictureExternal(lcevc->decoder, &desc, NULL, planes, picture);
|
||||
if (res != LCEVC_Success) {
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
res = LCEVC_LockPicture(lcevc->decoder, *picture, LCEVC_Access_Write, &lock);
|
||||
if (res != LCEVC_Success)
|
||||
return AVERROR_EXTERNAL;
|
||||
|
||||
res = LCEVC_GetPicturePlaneCount(lcevc->decoder, *picture, &planes);
|
||||
if (res != LCEVC_Success)
|
||||
return AVERROR_EXTERNAL;
|
||||
|
||||
for (unsigned i = 0; i < planes; i++) {
|
||||
LCEVC_PicturePlaneDesc plane;
|
||||
|
||||
res = LCEVC_GetPictureLockPlaneDesc(lcevc->decoder, lock, i, &plane);
|
||||
if (res != LCEVC_Success)
|
||||
return AVERROR_EXTERNAL;
|
||||
|
||||
data[i] = plane.firstSample;
|
||||
linesizes[i] = plane.rowByteStride;
|
||||
}
|
||||
|
||||
av_image_copy2(data, linesizes, frame->data, frame->linesize,
|
||||
frame->format, frame->width, frame->height);
|
||||
|
||||
res = LCEVC_UnlockPicture(lcevc->decoder, lock);
|
||||
if (res != LCEVC_Success)
|
||||
return AVERROR_EXTERNAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue