Mercurial > libavcodec.hg
changeset 8131:c30bdda1adb1 libavcodec
Taking advantage of the new ->execute API
author | romansh |
---|---|
date | Wed, 12 Nov 2008 21:13:28 +0000 |
parents | c45366b01126 |
children | 4cd689b64c36 |
files | dv.c dvdata.h |
diffstat | 2 files changed, 31 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/dv.c Wed Nov 12 20:23:36 2008 +0000 +++ b/dv.c Wed Nov 12 21:13:28 2008 +0000 @@ -92,9 +92,9 @@ static int dv_init_dynamic_tables(const DVprofile *d) { - int j,i,c,s,p; + int j,i,c,s,p,k; - if (d->work_chunks[dv_work_pool_size(d)-1]) + if (d->work_chunks[dv_work_pool_size(d)-1].buf_offset) return 0; p = i = 0; @@ -105,7 +105,9 @@ p += !(j%3); if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) && !(DV_PROFILE_IS_720p50(d) && s > 9)) { - d->work_chunks[i++] = (void*)(size_t)((p<<18)|(c << 16)|(s << 8)|j); + for (k=0; k<5; k++) + d->work_chunks[i].mb_coordinates[k] = d->video_place[(c*d->difseg_size+s)*27*5 + j*5 + k]; + d->work_chunks[i++].buf_offset = p; } p += 5; } @@ -381,17 +383,10 @@ } } -static inline void dv_calculate_mb_xy(DVVideoContext *s, int work_chunk, int m, int *mb_x, int *mb_y) +static inline void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y) { - int i, chan, seg, slot; - - chan = (work_chunk>>16)&0x03; - seg = (work_chunk>>8)&0xff; - slot = (work_chunk)&0xff; - - i = (chan*s->sys->difseg_size+seg)*27*5 + slot*5 + m; - *mb_x = s->sys->video_place[i] & 0xff; - *mb_y = s->sys->video_place[i] >> 8; + *mb_x = work_chunk->mb_coordinates[m] & 0xff; + *mb_y = work_chunk->mb_coordinates[m] >> 8; /* We work with 720p frames split in half. The odd half-frame (chan==2,3) is displaced :-( */ if (s->sys->height == 720 && !(s->buf[1]&0x0C)) { @@ -400,7 +395,7 @@ } /* mb_x and mb_y are in units of 8 pixels */ -static inline void dv_decode_video_segment(DVVideoContext *s, int work_chunk) +static inline void dv_decode_video_segment(DVVideoContext *s, DVwork_chunk *work_chunk) { int quant, dc, dct_mode, class1, j; int mb_index, mb_x, mb_y, last_index; @@ -424,7 +419,7 @@ memset(sblock, 0, sizeof(sblock)); /* pass 1 : read DC and AC coefficients in blocks */ - buf_ptr = &s->buf[(work_chunk>>18)*80]; + buf_ptr = &s->buf[work_chunk->buf_offset*80]; block1 = &sblock[0][0]; mb1 = mb_data; init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80); @@ -862,7 +857,7 @@ } } -static inline void dv_encode_video_segment(DVVideoContext *s, int work_chunk) +static inline void dv_encode_video_segment(DVVideoContext *s, DVwork_chunk *work_chunk) { int mb_index, i, j; int mb_x, mb_y, c_offset, linesize; @@ -881,7 +876,7 @@ assert((((int)block) & 15) == 0); - dif = &s->buf[(work_chunk>>18)*80]; + dif = &s->buf[work_chunk->buf_offset*80]; enc_blk = &enc_blks[0]; pb = &pbs[0]; for (mb_index = 0; mb_index < 5; mb_index++) { @@ -1013,14 +1008,14 @@ static int dv_decode_mt(AVCodecContext *avctx, void* sl) { - dv_decode_video_segment((DVVideoContext *)avctx->priv_data, *(size_t*)sl); + dv_decode_video_segment((DVVideoContext *)avctx->priv_data, (DVwork_chunk*)sl); return 0; } #ifdef CONFIG_DVVIDEO_ENCODER static int dv_encode_mt(AVCodecContext *avctx, void* sl) { - dv_encode_video_segment((DVVideoContext *)avctx->priv_data, *(size_t*)sl); + dv_encode_video_segment((DVVideoContext *)avctx->priv_data, (DVwork_chunk*)sl); return 0; } #endif @@ -1056,7 +1051,7 @@ s->buf = buf; avctx->execute(avctx, dv_decode_mt, s->sys->work_chunks, NULL, - dv_work_pool_size(s->sys), sizeof(void*)); + dv_work_pool_size(s->sys), sizeof(DVwork_chunk)); emms_c(); @@ -1209,7 +1204,7 @@ s->buf = buf; c->execute(c, dv_encode_mt, s->sys->work_chunks, NULL, - dv_work_pool_size(s->sys), sizeof(void*)); + dv_work_pool_size(s->sys), sizeof(DVwork_chunk)); emms_c();
--- a/dvdata.h Wed Nov 12 20:23:36 2008 +0000 +++ b/dvdata.h Wed Nov 12 21:13:28 2008 +0000 @@ -30,6 +30,11 @@ #include "libavutil/rational.h" #include "avcodec.h" +typedef struct DVwork_chunk { + uint16_t buf_offset; + uint16_t mb_coordinates[5]; +} DVwork_chunk; + /* * DVprofile is used to express the differences between various * DV flavors. For now it's primarily used for differentiating @@ -47,7 +52,7 @@ int height; /* picture height in pixels */ int width; /* picture width in pixels */ AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */ - void **work_chunks; /* each thread gets its own chunk of frame to work on */ + DVwork_chunk *work_chunks; /* each thread gets its own chunk of frame to work on */ const uint16_t *video_place; /* positions of all DV macroblocks */ enum PixelFormat pix_fmt; /* picture pixel format */ int bpm; /* blocks per macroblock */ @@ -6160,15 +6165,15 @@ 80, 80, 80, 80, 80, 80, 64, 64, }; -static void *work_chunks_dv25pal [1*12*27]; -static void *work_chunks_dv25pal411[1*12*27]; -static void *work_chunks_dv25ntsc [1*10*27]; -static void *work_chunks_dv50pal [2*12*27]; -static void *work_chunks_dv50ntsc [2*10*27]; -static void *work_chunks_dv100palp [2*12*27]; -static void *work_chunks_dv100ntscp[2*10*27]; -static void *work_chunks_dv100pali [4*12*27]; -static void *work_chunks_dv100ntsci[4*10*27]; +static DVwork_chunk work_chunks_dv25pal [1*12*27]; +static DVwork_chunk work_chunks_dv25pal411[1*12*27]; +static DVwork_chunk work_chunks_dv25ntsc [1*10*27]; +static DVwork_chunk work_chunks_dv50pal [2*12*27]; +static DVwork_chunk work_chunks_dv50ntsc [2*10*27]; +static DVwork_chunk work_chunks_dv100palp [2*12*27]; +static DVwork_chunk work_chunks_dv100ntscp[2*10*27]; +static DVwork_chunk work_chunks_dv100pali [4*12*27]; +static DVwork_chunk work_chunks_dv100ntsci[4*10*27]; static const DVprofile dv_profiles[] = { { .dsf = 0,