mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-14 02:50:11 +01:00
avcodec/snow: only allocate space for edges when encoding
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -69,19 +69,26 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_
|
|||||||
int ff_snow_get_buffer(SnowContext *s, AVFrame *frame)
|
int ff_snow_get_buffer(SnowContext *s, AVFrame *frame)
|
||||||
{
|
{
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
int edges_needed = av_codec_is_encoder(s->avctx->codec);
|
||||||
|
|
||||||
frame->width = s->avctx->width + 2 * EDGE_WIDTH;
|
frame->width = s->avctx->width ;
|
||||||
frame->height = s->avctx->height + 2 * EDGE_WIDTH;
|
frame->height = s->avctx->height;
|
||||||
|
if (edges_needed) {
|
||||||
|
frame->width += 2 * EDGE_WIDTH;
|
||||||
|
frame->height += 2 * EDGE_WIDTH;
|
||||||
|
}
|
||||||
if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
|
if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
for (i = 0; frame->data[i]; i++) {
|
if (edges_needed) {
|
||||||
int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) *
|
for (i = 0; frame->data[i]; i++) {
|
||||||
frame->linesize[i] +
|
int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) *
|
||||||
(EDGE_WIDTH >> (i ? s->chroma_h_shift : 0));
|
frame->linesize[i] +
|
||||||
frame->data[i] += offset;
|
(EDGE_WIDTH >> (i ? s->chroma_h_shift : 0));
|
||||||
|
frame->data[i] += offset;
|
||||||
|
}
|
||||||
|
frame->width = s->avctx->width;
|
||||||
|
frame->height = s->avctx->height;
|
||||||
}
|
}
|
||||||
frame->width = s->avctx->width;
|
|
||||||
frame->height = s->avctx->height;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user