Commit 777fd5a1 authored by rtognimp's avatar rtognimp

buffer hints, use reget_buffer, removed copy from previous frame


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3117 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent f6a3a14e
...@@ -57,7 +57,6 @@ typedef struct CinepakContext { ...@@ -57,7 +57,6 @@ typedef struct CinepakContext {
AVCodecContext *avctx; AVCodecContext *avctx;
DSPContext dsp; DSPContext dsp;
AVFrame frame; AVFrame frame;
AVFrame prev_frame;
unsigned char *data; unsigned char *data;
int size; int size;
...@@ -125,7 +124,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip, ...@@ -125,7 +124,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip,
uint8_t *eod = (data + size); uint8_t *eod = (data + size);
uint32_t flag, mask; uint32_t flag, mask;
cvid_codebook_t *codebook; cvid_codebook_t *codebook;
unsigned int i, j, x, y; unsigned int x, y;
uint32_t iy[4]; uint32_t iy[4];
uint32_t iu[2]; uint32_t iu[2];
uint32_t iv[2]; uint32_t iv[2];
...@@ -250,22 +249,6 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip, ...@@ -250,22 +249,6 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip,
} }
} }
} else {
/* copy from the previous frame */
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
s->frame.data[0][iy[i] + j] =
s->prev_frame.data[0][iy[i] + j];
}
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
s->frame.data[1][iu[i] + j] =
s->prev_frame.data[1][iu[i] + j];
s->frame.data[2][iv[i] + j] =
s->prev_frame.data[2][iv[i] + j];
}
}
} }
iy[0] += 4; iy[1] += 4; iy[0] += 4; iy[1] += 4;
...@@ -397,7 +380,7 @@ s->palette_video = 0; ...@@ -397,7 +380,7 @@ s->palette_video = 0;
avctx->has_b_frames = 0; avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx); dsputil_init(&s->dsp, avctx);
s->frame.data[0] = s->prev_frame.data[0] = NULL; s->frame.data[0] = NULL;
return 0; return 0;
} }
...@@ -411,19 +394,16 @@ static int cinepak_decode_frame(AVCodecContext *avctx, ...@@ -411,19 +394,16 @@ static int cinepak_decode_frame(AVCodecContext *avctx,
s->data = buf; s->data = buf;
s->size = buf_size; s->size = buf_size;
if (avctx->get_buffer(avctx, &s->frame)) { s->frame.reference = 1;
av_log(avctx, AV_LOG_ERROR, " Cinepak: get_buffer() failed\n"); s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
FF_BUFFER_HINTS_REUSABLE;
if (avctx->reget_buffer(avctx, &s->frame)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1; return -1;
} }
cinepak_decode(s); cinepak_decode(s);
if (s->prev_frame.data[0])
avctx->release_buffer(avctx, &s->prev_frame);
/* shuffle frames */
s->prev_frame = s->frame;
*data_size = sizeof(AVFrame); *data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame; *(AVFrame*)data = s->frame;
...@@ -435,8 +415,8 @@ static int cinepak_decode_end(AVCodecContext *avctx) ...@@ -435,8 +415,8 @@ static int cinepak_decode_end(AVCodecContext *avctx)
{ {
CinepakContext *s = (CinepakContext *)avctx->priv_data; CinepakContext *s = (CinepakContext *)avctx->priv_data;
if (s->prev_frame.data[0]) if (s->frame.data[0])
avctx->release_buffer(avctx, &s->prev_frame); avctx->release_buffer(avctx, &s->frame);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment