aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2007-02-25 15:33:38 +0000
committerAurelien Jacobs <aurel@gnuage.org>2007-02-25 15:33:38 +0000
commit704a2881bc7787592889a5c3d48ef4ce8398214d (patch)
tree6ca547f61957190d13f5ecfc2b5fec0e404afd7c
parent950d94ad3b232d6e4ee1ad1a1f60364f8e0dfbda (diff)
downloadffmpeg-704a2881bc7787592889a5c3d48ef4ce8398214d.tar.gz
Use pointers to avoid copying AVFrame.
This ensure get_buffer() won't be confused with an AVFrame pointer which looks like it wasn't released. Originally committed as revision 8124 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/vp5.c8
-rw-r--r--libavcodec/vp56.c50
-rw-r--r--libavcodec/vp56.h1
-rw-r--r--libavcodec/vp56data.h1
-rw-r--r--libavcodec/vp6.c8
5 files changed, 35 insertions, 33 deletions
diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c
index 2edacc4cac..8a8c217c0b 100644
--- a/libavcodec/vp5.c
+++ b/libavcodec/vp5.c
@@ -41,10 +41,10 @@ static int vp5_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
int rows, cols;
vp56_init_range_decoder(&s->c, buf, buf_size);
- s->frames[VP56_FRAME_CURRENT].key_frame = !vp56_rac_get(c);
+ s->framep[VP56_FRAME_CURRENT]->key_frame = !vp56_rac_get(c);
vp56_rac_get(c);
vp56_init_dequant(s, vp56_rac_gets(c, 6));
- if (s->frames[VP56_FRAME_CURRENT].key_frame)
+ if (s->framep[VP56_FRAME_CURRENT]->key_frame)
{
vp56_rac_gets(c, 8);
if(vp56_rac_gets(c, 5) > 5)
@@ -145,7 +145,7 @@ static void vp5_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp5_dccv_pct[pt][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_dccv[pt][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_dccv[pt][node] = def_prob[node];
}
@@ -156,7 +156,7 @@ static void vp5_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp5_ract_pct[ct][pt][cg][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
}
diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c
index d0165b67fe..a3fec1d2bf 100644
--- a/libavcodec/vp56.c
+++ b/libavcodec/vp56.c
@@ -326,7 +326,7 @@ static void vp56_mc(vp56_context_t *s, int b, uint8_t *src,
int stride, int x, int y)
{
int plane = vp56_b6to3[b];
- uint8_t *dst= s->frames[VP56_FRAME_CURRENT].data[plane]+s->block_offset[b];
+ uint8_t *dst=s->framep[VP56_FRAME_CURRENT]->data[plane]+s->block_offset[b];
uint8_t *src_block;
int src_offset;
int overlap_offset = 0;
@@ -337,7 +337,7 @@ static void vp56_mc(vp56_context_t *s, int b, uint8_t *src,
if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY
- && !s->frames[VP56_FRAME_CURRENT].key_frame))
+ && !s->framep[VP56_FRAME_CURRENT]->key_frame))
deblock_filtering = 0;
dx = s->mv[b].x / s->vp56_coord_div[b];
@@ -400,7 +400,7 @@ static void vp56_decode_mb(vp56_context_t *s, int row, int col)
vp56_frame_t ref_frame;
int b, plan, off;
- if (s->frames[VP56_FRAME_CURRENT].key_frame)
+ if (s->framep[VP56_FRAME_CURRENT]->key_frame)
mb_type = VP56_MB_INTRA;
else
mb_type = vp56_decode_mv(s, row, col);
@@ -412,8 +412,8 @@ static void vp56_decode_mb(vp56_context_t *s, int row, int col)
vp56_add_predictors_dc(s, ref_frame);
- frame_current = &s->frames[VP56_FRAME_CURRENT];
- frame_ref = &s->frames[ref_frame];
+ frame_current = s->framep[VP56_FRAME_CURRENT];
+ frame_ref = s->framep[ref_frame];
switch (mb_type) {
case VP56_MB_INTRA:
@@ -459,7 +459,7 @@ static void vp56_decode_mb(vp56_context_t *s, int row, int col)
static int vp56_size_changed(AVCodecContext *avctx, vp56_context_t *s)
{
- int stride = s->frames[VP56_FRAME_CURRENT].linesize[0];
+ int stride = s->framep[VP56_FRAME_CURRENT]->linesize[0];
int i;
s->plane_width[0] = s->avctx->coded_width;
@@ -468,7 +468,7 @@ static int vp56_size_changed(AVCodecContext *avctx, vp56_context_t *s)
s->plane_height[1] = s->plane_height[2] = s->avctx->coded_height/2;
for (i=0; i<3; i++)
- s->stride[i] = s->flip * s->frames[VP56_FRAME_CURRENT].linesize[i];
+ s->stride[i] = s->flip * s->framep[VP56_FRAME_CURRENT]->linesize[i];
s->mb_width = (s->avctx->coded_width+15) / 16;
s->mb_height = (s->avctx->coded_height+15) / 16;
@@ -495,7 +495,7 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
uint8_t *buf, int buf_size)
{
vp56_context_t *s = avctx->priv_data;
- AVFrame *const p = &s->frames[VP56_FRAME_CURRENT];
+ AVFrame *const p = s->framep[VP56_FRAME_CURRENT];
AVFrame *picture = data;
int mb_row, mb_col, mb_row_flip, mb_offset = 0;
int block, y, uv, stride_y, stride_uv;
@@ -594,22 +594,22 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
- if (s->frames[VP56_FRAME_PREVIOUS].data[0]
- && (s->frames[VP56_FRAME_PREVIOUS].data[0]
- != s->frames[VP56_FRAME_GOLDEN].data[0])) {
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_PREVIOUS]);
- }
+ if (s->framep[VP56_FRAME_PREVIOUS] == s->framep[VP56_FRAME_GOLDEN])
+ FFSWAP(AVFrame *, s->framep[VP56_FRAME_PREVIOUS],
+ s->framep[VP56_FRAME_UNUSED]);
+ else if (s->framep[VP56_FRAME_PREVIOUS]->data[0])
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]);
if (p->key_frame || golden_frame) {
- if (s->frames[VP56_FRAME_GOLDEN].data[0])
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_GOLDEN]);
- s->frames[VP56_FRAME_GOLDEN] = *p;
+ if (s->framep[VP56_FRAME_GOLDEN]->data[0])
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN]);
+ s->framep[VP56_FRAME_GOLDEN] = p;
}
- s->frames[VP56_FRAME_PREVIOUS] = *p;
+ FFSWAP(AVFrame *, s->framep[VP56_FRAME_CURRENT],
+ s->framep[VP56_FRAME_PREVIOUS]);
*picture = *p;
*data_size = sizeof(AVPicture);
- s->frames[VP56_FRAME_CURRENT].data[0] = NULL;
return buf_size;
}
@@ -628,7 +628,8 @@ void vp56_init(vp56_context_t *s, AVCodecContext *avctx, int flip)
avcodec_set_dimensions(s->avctx, 0, 0);
for (i=0; i<3; i++)
- s->frames[i].data[0] = NULL;
+ s->framep[i] = &s->frames[i];
+ s->framep[VP56_FRAME_UNUSED] = s->framep[VP56_FRAME_GOLDEN];
s->edge_emu_buffer_alloc = NULL;
s->above_blocks = NULL;
@@ -656,11 +657,10 @@ int vp56_free(AVCodecContext *avctx)
av_free(s->above_blocks);
av_free(s->macroblocks);
av_free(s->edge_emu_buffer_alloc);
- if (s->frames[VP56_FRAME_GOLDEN].data[0]
- && (s->frames[VP56_FRAME_PREVIOUS].data[0]
- != s->frames[VP56_FRAME_GOLDEN].data[0]))
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_GOLDEN]);
- if (s->frames[VP56_FRAME_PREVIOUS].data[0])
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_PREVIOUS]);
+ if (s->framep[VP56_FRAME_GOLDEN]->data[0]
+ && (s->framep[VP56_FRAME_PREVIOUS] != s->framep[VP56_FRAME_GOLDEN]))
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN]);
+ if (s->framep[VP56_FRAME_PREVIOUS]->data[0])
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]);
return 0;
}
diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h
index 50e2015504..fb8bbba6fc 100644
--- a/libavcodec/vp56.h
+++ b/libavcodec/vp56.h
@@ -73,6 +73,7 @@ struct vp56_context {
DSPContext dsp;
ScanTable scantable;
AVFrame frames[3];
+ AVFrame *framep[4];
uint8_t *edge_emu_buffer_alloc;
uint8_t *edge_emu_buffer;
vp56_range_coder_t c;
diff --git a/libavcodec/vp56data.h b/libavcodec/vp56data.h
index dbf92dd68e..d784b9803a 100644
--- a/libavcodec/vp56data.h
+++ b/libavcodec/vp56data.h
@@ -30,6 +30,7 @@ typedef enum {
VP56_FRAME_CURRENT = 0,
VP56_FRAME_PREVIOUS = 1,
VP56_FRAME_GOLDEN = 2,
+ VP56_FRAME_UNUSED = 3,
} vp56_frame_t;
typedef enum {
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 9a2afd8fa0..2e904b7e0a 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -50,10 +50,10 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
int res = 1;
int separated_coeff = buf[0] & 1;
- s->frames[VP56_FRAME_CURRENT].key_frame = !(buf[0] & 0x80);
+ s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80);
vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
- if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
sub_version = buf[1] >> 3;
if (sub_version > 8)
return 0;
@@ -205,7 +205,7 @@ static void vp6_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp6_dccv_pct[pt][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_dccv[pt][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_dccv[pt][node] = def_prob[node];
}
@@ -228,7 +228,7 @@ static void vp6_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp6_ract_pct[ct][pt][cg][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
}