Commit aa066582 authored by Roman Shaposhnik's avatar Roman Shaposhnik

Moving dv_anchor back to the global scope. This creates a tiny memory

   leak for cases like dlopening libavcodec.so and such, but I still
   don't know how to catch such events.

Originally committed as revision 4818 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent faf824df
...@@ -49,11 +49,11 @@ typedef struct DVVideoContext { ...@@ -49,11 +49,11 @@ typedef struct DVVideoContext {
void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size); void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size);
void (*fdct[2])(DCTELEM *block); void (*fdct[2])(DCTELEM *block);
void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block); void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block);
/* MultiThreading */
uint8_t** dv_anchor;
} DVVideoContext; } DVVideoContext;
/* MultiThreading - applies to entire DV codec, not just the avcontext */
uint8_t** dv_anchor;
#define TEX_VLC_BITS 9 #define TEX_VLC_BITS 9
#ifdef DV_CODEC_TINY_TARGET #ifdef DV_CODEC_TINY_TARGET
...@@ -118,12 +118,12 @@ static int dvvideo_init(AVCodecContext *avctx) ...@@ -118,12 +118,12 @@ static int dvvideo_init(AVCodecContext *avctx)
return -ENOMEM; return -ENOMEM;
/* dv_anchor lets each thread know its Id */ /* dv_anchor lets each thread know its Id */
s->dv_anchor = av_malloc(12*27*sizeof(void*)); dv_anchor = av_malloc(12*27*sizeof(void*));
if (!s->dv_anchor) { if (!dv_anchor) {
return -ENOMEM; return -ENOMEM;
} }
for (i=0; i<12*27; i++) for (i=0; i<12*27; i++)
s->dv_anchor[i] = (void*)(size_t)i; dv_anchor[i] = (void*)(size_t)i;
/* it's faster to include sign bit in a generic VLC parsing scheme */ /* it's faster to include sign bit in a generic VLC parsing scheme */
for (i=0, j=0; i<NB_DV_VLC; i++, j++) { for (i=0, j=0; i<NB_DV_VLC; i++, j++) {
...@@ -150,10 +150,9 @@ static int dvvideo_init(AVCodecContext *avctx) ...@@ -150,10 +150,9 @@ static int dvvideo_init(AVCodecContext *avctx)
new_dv_vlc_len, 1, 1, new_dv_vlc_bits, 2, 2, 0); new_dv_vlc_len, 1, 1, new_dv_vlc_bits, 2, 2, 0);
dv_rl_vlc = av_mallocz_static(dv_vlc.table_size * sizeof(RL_VLC_ELEM)); dv_rl_vlc = av_mallocz_static(dv_vlc.table_size * sizeof(RL_VLC_ELEM));
if (!dv_rl_vlc) { if (!dv_rl_vlc)
av_free(s->dv_anchor);
return -ENOMEM; return -ENOMEM;
}
for(i = 0; i < dv_vlc.table_size; i++){ for(i = 0; i < dv_vlc.table_size; i++){
int code= dv_vlc.table[i][0]; int code= dv_vlc.table[i][0];
int len = dv_vlc.table[i][1]; int len = dv_vlc.table[i][1];
...@@ -939,7 +938,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, ...@@ -939,7 +938,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
s->picture.top_field_first = 0; s->picture.top_field_first = 0;
s->buf = buf; s->buf = buf;
avctx->execute(avctx, dv_decode_mt, (void**)&s->dv_anchor[0], NULL, avctx->execute(avctx, dv_decode_mt, (void**)&dv_anchor[0], NULL,
s->sys->difseg_size * 27); s->sys->difseg_size * 27);
emms_c(); emms_c();
...@@ -968,7 +967,7 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size, ...@@ -968,7 +967,7 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size,
s->picture.pict_type = FF_I_TYPE; s->picture.pict_type = FF_I_TYPE;
s->buf = buf; s->buf = buf;
c->execute(c, dv_encode_mt, (void**)&s->dv_anchor[0], NULL, c->execute(c, dv_encode_mt, (void**)&dv_anchor[0], NULL,
s->sys->difseg_size * 27); s->sys->difseg_size * 27);
emms_c(); emms_c();
...@@ -977,9 +976,6 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size, ...@@ -977,9 +976,6 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size,
static int dvvideo_close(AVCodecContext *c) static int dvvideo_close(AVCodecContext *c)
{ {
DVVideoContext *s = c->priv_data;
av_free(s->dv_anchor);
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