rv10 cleanup (de)muxer still needs to be cleaned up (still searching volunteer for that ;) )

Originally committed as revision 988 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 23 years ago
parent e41e834272
commit 144f062500
  1. 18
      libav/rm.c
  2. 17
      libavcodec/avcodec.h
  3. 99
      libavcodec/rv10.c

@ -591,12 +591,9 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
h263_hack_version = get_be32(pb);
switch(h263_hack_version) {
case 0x10000000:
st->codec.sub_id = 0;
st->codec.codec_id = CODEC_ID_RV10;
break;
case 0x10003000:
case 0x10003001:
st->codec.sub_id = 3;
st->codec.sub_id = h263_hack_version;
st->codec.codec_id = CODEC_ID_RV10;
break;
default:
@ -681,7 +678,6 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
goto redo;
}
#if 0 // XXX/FIXME this is done in the codec currently, but should be done here ...
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
int full_frame, h, pic_num;
@ -705,15 +701,11 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
/* picture number */
pic_num= get_byte(pb);
av_new_packet(pkt, len+1);
pkt->stream_index = i;
//XXX/FIXME: is this a good idea?
pkt->data[0]= h; //store header, its needed for decoding
get_buffer(pb, pkt->data+1, len);
//XXX/FIXME/HACK, demuxer should be fixed to send complete frames ...
if(st->codec.slice_offset==NULL) st->codec.slice_offset= (int*)malloc(sizeof(int));
st->codec.slice_count= full_frame;
st->codec.slice_offset[0]= 0;
}
#endif
av_new_packet(pkt, len);
pkt->stream_index = i;

@ -5,8 +5,8 @@
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4629
#define LIBAVCODEC_BUILD_STR "4629"
#define LIBAVCODEC_BUILD 4630
#define LIBAVCODEC_BUILD_STR "4630"
enum CodecID {
CODEC_ID_NONE,
@ -699,6 +699,19 @@ typedef struct AVCodecContext {
#define FF_IDCT_MLIB 6
#define FF_IDCT_ARM 7
/**
* slice count
* encoding: set by lavc
* decoding: set by user (or 0)
*/
int slice_count;
/**
* slice offsets in the frame in bytes
* encoding: set/allocated by lavc
* decoding: set/allocated by user (or NULL)
*/
int *slice_offset;
//FIXME this should be reordered after kabis API is finished ...
//TODO kill kabi
/*

@ -265,36 +265,17 @@ static int get_num(GetBitContext *gb)
/* read RV 1.0 compatible frame header */
static int rv10_decode_picture_header(MpegEncContext *s)
{
int mb_count, pb_frame, marker, h, full_frame;
int pic_num, unk;
//XXX/FIXME this should be done in the demuxer not here
/* skip packet header */
h = get_bits(&s->gb, 8);
if ((h & 0xc0) == 0xc0) {
int len, pos;
full_frame = 1;
len = get_num(&s->gb);
pos = get_num(&s->gb);
//printf("pos:%d\n",len);
} else {
int seq, frame_size, pos;
full_frame = 0;
seq = get_bits(&s->gb, 8);
frame_size = get_num(&s->gb);
pos = get_num(&s->gb);
//printf("seq:%d, size:%d, pos:%d\n",seq,frame_size,pos);
}
/* picture number */
pic_num= get_bits(&s->gb, 8);
int mb_count, pb_frame, marker, full_frame, unk;
full_frame= s->avctx->slice_count==1;
//printf("ff:%d\n", full_frame);
marker = get_bits(&s->gb, 1);
if (get_bits(&s->gb, 1))
s->pict_type = P_TYPE;
else
s->pict_type = I_TYPE;
//printf("h:%d ver:%d\n",h,s->rv10_version);
//printf("h:%X ver:%d\n",h,s->rv10_version);
if(!marker) printf("marker missing\n");
pb_frame = get_bits(&s->gb, 1);
@ -329,7 +310,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
}
/* if multiple packets per frame are sent, the position at which
to display the macro blocks is coded here */
if (!full_frame) {
if ((!full_frame) || show_bits(&s->gb, 12)==0) {
s->mb_x = get_bits(&s->gb, 6); /* mb_x */
s->mb_y = get_bits(&s->gb, 6); /* mb_y */
mb_count = get_bits(&s->gb, 12);
@ -358,8 +339,7 @@ static int rv10_decode_init(AVCodecContext *avctx)
s->height = avctx->height;
s->h263_rv10 = 1;
if(avctx->extradata_size >= 8){
switch(((uint32_t*)avctx->extradata)[1]){
switch(avctx->sub_id){
case 0x10000000:
s->rv10_version= 0;
s->h263_long_vectors=0;
@ -373,13 +353,9 @@ static int rv10_decode_init(AVCodecContext *avctx)
s->h263_long_vectors=0;
break;
default:
fprintf(stderr, "unknown header %X\n", ((uint32_t*)avctx->extradata)[1]);
}
}else{
// for backward compatibility
s->rv10_version= avctx->sub_id;
fprintf(stderr, "unknown header %X\n", avctx->sub_id);
}
//printf("ver:%X\n", avctx->sub_id);
s->flags= avctx->flags;
if (MPV_common_init(s) < 0)
@ -412,24 +388,12 @@ static int rv10_decode_end(AVCodecContext *avctx)
return 0;
}
static int rv10_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
static int rv10_decode_packet(AVCodecContext *avctx,
UINT8 *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i, mb_count, mb_pos, left;
DCTELEM block[6][64];
AVPicture *pict = data;
#ifdef DEBUG
printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
#endif
/* no supplementary picture */
if (buf_size == 0) {
*data_size = 0;
return 0;
}
init_get_bits(&s->gb, buf, buf_size);
@ -510,8 +474,46 @@ static int rv10_decode_frame(AVCodecContext *avctx,
}
}
if (s->mb_x == 0 &&
s->mb_y == s->mb_height) {
return buf_size;
}
static int rv10_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i;
AVPicture *pict = data;
#ifdef DEBUG
printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
#endif
/* no supplementary picture */
if (buf_size == 0) {
*data_size = 0;
return 0;
}
if(avctx->slice_count){
for(i=0; i<avctx->slice_count; i++){
int offset= avctx->slice_offset[i];
int size;
if(i+1 == avctx->slice_count)
size= buf_size - offset;
else
size= avctx->slice_offset[i+1] - offset;
if( rv10_decode_packet(avctx, buf+offset, size) < 0 )
return -1;
}
}else{
if( rv10_decode_packet(avctx, buf, buf_size) < 0 )
return -1;
}
if(s->mb_y>=s->mb_height){
MPV_frame_end(s);
pict->data[0] = s->current_picture[0];
@ -523,9 +525,10 @@ static int rv10_decode_frame(AVCodecContext *avctx,
avctx->quality = s->qscale;
*data_size = sizeof(AVPicture);
} else {
}else{
*data_size = 0;
}
return buf_size;
}

Loading…
Cancel
Save