aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-20 17:52:08 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-20 17:52:55 +0100
commit7c6cf689d825ee6ffefce11b1935c475c7ef5807 (patch)
treeabd0d4d7dc1fbd74ae4b8e696c9d9f71069a916f /libavcodec
parentd83707c64197de354419faa1816f6ec3e7baf7ba (diff)
downloadffmpeg-7c6cf689d825ee6ffefce11b1935c475c7ef5807.tar.gz
avcodec/diracdec: allocate edges internally instead of depending on CODEC_FLAG_EMU_EDGE being not set
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/diracdec.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index d437e14ce5..0ab74749d5 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -398,11 +398,6 @@ static av_cold int dirac_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
s->frame_number = -1;
- if (avctx->flags&CODEC_FLAG_EMU_EDGE) {
- av_log(avctx, AV_LOG_ERROR, "Edge emulation not supported!\n");
- return AVERROR_PATCHWELCOME;
- }
-
ff_dsputil_init(&s->dsp, avctx);
ff_diracdsp_init(&s->diracdsp);
@@ -1646,6 +1641,29 @@ static int dirac_decode_frame_internal(DiracContext *s)
return 0;
}
+static int get_buffer_with_edge(AVCodecContext *avctx, AVFrame *f, int flags)
+{
+ int ret, i;
+ int chroma_x_shift, chroma_y_shift;
+ avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift, &chroma_y_shift);
+
+ f->width = avctx->width + 2 * EDGE_WIDTH;
+ f->height = avctx->height + 2 * EDGE_WIDTH + 2;
+ ret = ff_get_buffer(avctx, f, flags);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; f->data[i]; i++) {
+ int offset = (EDGE_WIDTH >> (i && i<3 ? chroma_y_shift : 0)) *
+ f->linesize[i] + 32;
+ f->data[i] += offset;
+ }
+ f->width = avctx->width;
+ f->height = avctx->height;
+
+ return 0;
+}
+
/**
* Dirac Specification ->
* 11.1.1 Picture Header. picture_header()
@@ -1689,7 +1707,7 @@ static int dirac_decode_picture_header(DiracContext *s)
for (j = 0; j < MAX_FRAMES; j++)
if (!s->all_frames[j].avframe->data[0]) {
s->ref_pics[i] = &s->all_frames[j];
- ff_get_buffer(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
+ get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
break;
}
}
@@ -1829,7 +1847,7 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
pic->avframe->key_frame = s->num_refs == 0; /* [DIRAC_STD] is_intra() */
pic->avframe->pict_type = s->num_refs + 1; /* Definition of AVPictureType in avutil.h */
- if ((ret = ff_get_buffer(avctx, pic->avframe, (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
+ if ((ret = get_buffer_with_edge(avctx, pic->avframe, (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
return ret;
s->current_picture = pic;
s->plane[0].stride = pic->avframe->linesize[0];