Mercurial > libavcodec.hg
comparison dv.c @ 3016:97e6c0f82182 libavcodec
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.
author | romansh |
---|---|
date | Fri, 06 Jan 2006 19:19:39 +0000 |
parents | d377b0788381 |
children | 0b546eab515d |
comparison
equal
deleted
inserted
replaced
3015:1720680830c7 | 3016:97e6c0f82182 |
---|---|
47 uint8_t dv_idct_shift[2][2][22][64]; | 47 uint8_t dv_idct_shift[2][2][22][64]; |
48 | 48 |
49 void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size); | 49 void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size); |
50 void (*fdct[2])(DCTELEM *block); | 50 void (*fdct[2])(DCTELEM *block); |
51 void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block); | 51 void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block); |
52 | |
53 /* MultiThreading */ | |
54 uint8_t** dv_anchor; | |
55 } DVVideoContext; | 52 } DVVideoContext; |
53 | |
54 /* MultiThreading - applies to entire DV codec, not just the avcontext */ | |
55 uint8_t** dv_anchor; | |
56 | 56 |
57 #define TEX_VLC_BITS 9 | 57 #define TEX_VLC_BITS 9 |
58 | 58 |
59 #ifdef DV_CODEC_TINY_TARGET | 59 #ifdef DV_CODEC_TINY_TARGET |
60 #define DV_VLC_MAP_RUN_SIZE 15 | 60 #define DV_VLC_MAP_RUN_SIZE 15 |
116 dv_vlc_map = av_mallocz_static(DV_VLC_MAP_LEV_SIZE*DV_VLC_MAP_RUN_SIZE*sizeof(struct dv_vlc_pair)); | 116 dv_vlc_map = av_mallocz_static(DV_VLC_MAP_LEV_SIZE*DV_VLC_MAP_RUN_SIZE*sizeof(struct dv_vlc_pair)); |
117 if (!dv_vlc_map) | 117 if (!dv_vlc_map) |
118 return -ENOMEM; | 118 return -ENOMEM; |
119 | 119 |
120 /* dv_anchor lets each thread know its Id */ | 120 /* dv_anchor lets each thread know its Id */ |
121 s->dv_anchor = av_malloc(12*27*sizeof(void*)); | 121 dv_anchor = av_malloc(12*27*sizeof(void*)); |
122 if (!s->dv_anchor) { | 122 if (!dv_anchor) { |
123 return -ENOMEM; | 123 return -ENOMEM; |
124 } | 124 } |
125 for (i=0; i<12*27; i++) | 125 for (i=0; i<12*27; i++) |
126 s->dv_anchor[i] = (void*)(size_t)i; | 126 dv_anchor[i] = (void*)(size_t)i; |
127 | 127 |
128 /* it's faster to include sign bit in a generic VLC parsing scheme */ | 128 /* it's faster to include sign bit in a generic VLC parsing scheme */ |
129 for (i=0, j=0; i<NB_DV_VLC; i++, j++) { | 129 for (i=0, j=0; i<NB_DV_VLC; i++, j++) { |
130 new_dv_vlc_bits[j] = dv_vlc_bits[i]; | 130 new_dv_vlc_bits[j] = dv_vlc_bits[i]; |
131 new_dv_vlc_len[j] = dv_vlc_len[i]; | 131 new_dv_vlc_len[j] = dv_vlc_len[i]; |
148 to accelerate the parsing of partial codes */ | 148 to accelerate the parsing of partial codes */ |
149 init_vlc(&dv_vlc, TEX_VLC_BITS, j, | 149 init_vlc(&dv_vlc, TEX_VLC_BITS, j, |
150 new_dv_vlc_len, 1, 1, new_dv_vlc_bits, 2, 2, 0); | 150 new_dv_vlc_len, 1, 1, new_dv_vlc_bits, 2, 2, 0); |
151 | 151 |
152 dv_rl_vlc = av_mallocz_static(dv_vlc.table_size * sizeof(RL_VLC_ELEM)); | 152 dv_rl_vlc = av_mallocz_static(dv_vlc.table_size * sizeof(RL_VLC_ELEM)); |
153 if (!dv_rl_vlc) { | 153 if (!dv_rl_vlc) |
154 av_free(s->dv_anchor); | |
155 return -ENOMEM; | 154 return -ENOMEM; |
156 } | 155 |
157 for(i = 0; i < dv_vlc.table_size; i++){ | 156 for(i = 0; i < dv_vlc.table_size; i++){ |
158 int code= dv_vlc.table[i][0]; | 157 int code= dv_vlc.table[i][0]; |
159 int len = dv_vlc.table[i][1]; | 158 int len = dv_vlc.table[i][1]; |
160 int level, run; | 159 int level, run; |
161 | 160 |
937 } | 936 } |
938 s->picture.interlaced_frame = 1; | 937 s->picture.interlaced_frame = 1; |
939 s->picture.top_field_first = 0; | 938 s->picture.top_field_first = 0; |
940 | 939 |
941 s->buf = buf; | 940 s->buf = buf; |
942 avctx->execute(avctx, dv_decode_mt, (void**)&s->dv_anchor[0], NULL, | 941 avctx->execute(avctx, dv_decode_mt, (void**)&dv_anchor[0], NULL, |
943 s->sys->difseg_size * 27); | 942 s->sys->difseg_size * 27); |
944 | 943 |
945 emms_c(); | 944 emms_c(); |
946 | 945 |
947 /* return image */ | 946 /* return image */ |
966 s->picture = *((AVFrame *)data); | 965 s->picture = *((AVFrame *)data); |
967 s->picture.key_frame = 1; | 966 s->picture.key_frame = 1; |
968 s->picture.pict_type = FF_I_TYPE; | 967 s->picture.pict_type = FF_I_TYPE; |
969 | 968 |
970 s->buf = buf; | 969 s->buf = buf; |
971 c->execute(c, dv_encode_mt, (void**)&s->dv_anchor[0], NULL, | 970 c->execute(c, dv_encode_mt, (void**)&dv_anchor[0], NULL, |
972 s->sys->difseg_size * 27); | 971 s->sys->difseg_size * 27); |
973 | 972 |
974 emms_c(); | 973 emms_c(); |
975 return s->sys->frame_size; | 974 return s->sys->frame_size; |
976 } | 975 } |
977 | 976 |
978 static int dvvideo_close(AVCodecContext *c) | 977 static int dvvideo_close(AVCodecContext *c) |
979 { | 978 { |
980 DVVideoContext *s = c->priv_data; | |
981 | |
982 av_free(s->dv_anchor); | |
983 | 979 |
984 return 0; | 980 return 0; |
985 } | 981 } |
986 | 982 |
987 | 983 |