mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
Taking advantage of the new ->execute API
Originally committed as revision 15806 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
77753f874a
commit
2ae7e12430
@ -92,9 +92,9 @@ static inline int dv_work_pool_size(const DVprofile *d)
|
|||||||
|
|
||||||
static int dv_init_dynamic_tables(const DVprofile *d)
|
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;
|
return 0;
|
||||||
|
|
||||||
p = i = 0;
|
p = i = 0;
|
||||||
@ -105,7 +105,9 @@ static int dv_init_dynamic_tables(const DVprofile *d)
|
|||||||
p += !(j%3);
|
p += !(j%3);
|
||||||
if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&
|
if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&
|
||||||
!(DV_PROFILE_IS_720p50(d) && s > 9)) {
|
!(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;
|
p += 5;
|
||||||
}
|
}
|
||||||
@ -381,17 +383,10 @@ static inline void bit_copy(PutBitContext *pb, GetBitContext *gb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
*mb_x = work_chunk->mb_coordinates[m] & 0xff;
|
||||||
|
*mb_y = work_chunk->mb_coordinates[m] >> 8;
|
||||||
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;
|
|
||||||
|
|
||||||
/* We work with 720p frames split in half. The odd half-frame (chan==2,3) is displaced :-( */
|
/* 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)) {
|
if (s->sys->height == 720 && !(s->buf[1]&0x0C)) {
|
||||||
@ -400,7 +395,7 @@ static inline void dv_calculate_mb_xy(DVVideoContext *s, int work_chunk, int m,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* mb_x and mb_y are in units of 8 pixels */
|
/* 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 quant, dc, dct_mode, class1, j;
|
||||||
int mb_index, mb_x, mb_y, last_index;
|
int mb_index, mb_x, mb_y, last_index;
|
||||||
@ -424,7 +419,7 @@ static inline void dv_decode_video_segment(DVVideoContext *s, int work_chunk)
|
|||||||
memset(sblock, 0, sizeof(sblock));
|
memset(sblock, 0, sizeof(sblock));
|
||||||
|
|
||||||
/* pass 1 : read DC and AC coefficients in blocks */
|
/* 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];
|
block1 = &sblock[0][0];
|
||||||
mb1 = mb_data;
|
mb1 = mb_data;
|
||||||
init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
|
init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
|
||||||
@ -862,7 +857,7 @@ static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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_index, i, j;
|
||||||
int mb_x, mb_y, c_offset, linesize;
|
int mb_x, mb_y, c_offset, linesize;
|
||||||
@ -881,7 +876,7 @@ static inline void dv_encode_video_segment(DVVideoContext *s, int work_chunk)
|
|||||||
|
|
||||||
assert((((int)block) & 15) == 0);
|
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];
|
enc_blk = &enc_blks[0];
|
||||||
pb = &pbs[0];
|
pb = &pbs[0];
|
||||||
for (mb_index = 0; mb_index < 5; mb_index++) {
|
for (mb_index = 0; mb_index < 5; mb_index++) {
|
||||||
@ -1013,14 +1008,14 @@ static inline void dv_encode_video_segment(DVVideoContext *s, int work_chunk)
|
|||||||
|
|
||||||
static int dv_decode_mt(AVCodecContext *avctx, void* sl)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DVVIDEO_ENCODER
|
#ifdef CONFIG_DVVIDEO_ENCODER
|
||||||
static int dv_encode_mt(AVCodecContext *avctx, void* sl)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1056,7 +1051,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
|
|
||||||
s->buf = buf;
|
s->buf = buf;
|
||||||
avctx->execute(avctx, dv_decode_mt, s->sys->work_chunks, NULL,
|
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();
|
emms_c();
|
||||||
|
|
||||||
@ -1209,7 +1204,7 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size,
|
|||||||
|
|
||||||
s->buf = buf;
|
s->buf = buf;
|
||||||
c->execute(c, dv_encode_mt, s->sys->work_chunks, NULL,
|
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();
|
emms_c();
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@
|
|||||||
#include "libavutil/rational.h"
|
#include "libavutil/rational.h"
|
||||||
#include "avcodec.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
|
* DVprofile is used to express the differences between various
|
||||||
* DV flavors. For now it's primarily used for differentiating
|
* DV flavors. For now it's primarily used for differentiating
|
||||||
@ -47,7 +52,7 @@ typedef struct DVprofile {
|
|||||||
int height; /* picture height in pixels */
|
int height; /* picture height in pixels */
|
||||||
int width; /* picture width in pixels */
|
int width; /* picture width in pixels */
|
||||||
AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */
|
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 */
|
const uint16_t *video_place; /* positions of all DV macroblocks */
|
||||||
enum PixelFormat pix_fmt; /* picture pixel format */
|
enum PixelFormat pix_fmt; /* picture pixel format */
|
||||||
int bpm; /* blocks per macroblock */
|
int bpm; /* blocks per macroblock */
|
||||||
@ -6160,15 +6165,15 @@ static const uint8_t block_sizes_dv100[8] = {
|
|||||||
80, 80, 80, 80, 80, 80, 64, 64,
|
80, 80, 80, 80, 80, 80, 64, 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void *work_chunks_dv25pal [1*12*27];
|
static DVwork_chunk work_chunks_dv25pal [1*12*27];
|
||||||
static void *work_chunks_dv25pal411[1*12*27];
|
static DVwork_chunk work_chunks_dv25pal411[1*12*27];
|
||||||
static void *work_chunks_dv25ntsc [1*10*27];
|
static DVwork_chunk work_chunks_dv25ntsc [1*10*27];
|
||||||
static void *work_chunks_dv50pal [2*12*27];
|
static DVwork_chunk work_chunks_dv50pal [2*12*27];
|
||||||
static void *work_chunks_dv50ntsc [2*10*27];
|
static DVwork_chunk work_chunks_dv50ntsc [2*10*27];
|
||||||
static void *work_chunks_dv100palp [2*12*27];
|
static DVwork_chunk work_chunks_dv100palp [2*12*27];
|
||||||
static void *work_chunks_dv100ntscp[2*10*27];
|
static DVwork_chunk work_chunks_dv100ntscp[2*10*27];
|
||||||
static void *work_chunks_dv100pali [4*12*27];
|
static DVwork_chunk work_chunks_dv100pali [4*12*27];
|
||||||
static void *work_chunks_dv100ntsci[4*10*27];
|
static DVwork_chunk work_chunks_dv100ntsci[4*10*27];
|
||||||
|
|
||||||
static const DVprofile dv_profiles[] = {
|
static const DVprofile dv_profiles[] = {
|
||||||
{ .dsf = 0,
|
{ .dsf = 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user