Mercurial > libavcodec.hg
changeset 556:762c67fd4078 libavcodec
uvlinesize
export has_b_frames
mb_skip with more than 2 ip buffers
author | michaelni |
---|---|
date | Mon, 15 Jul 2002 14:15:10 +0000 |
parents | fe951e388d34 |
children | c1e1be461662 |
files | avcodec.h h263dec.c mpeg12.c mpegvideo.c mpegvideo.h msmpeg4.c rv10.c |
diffstat | 7 files changed, 78 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/avcodec.h Mon Jul 15 07:43:22 2002 +0000 +++ b/avcodec.h Mon Jul 15 14:15:10 2002 +0000 @@ -5,8 +5,8 @@ #define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION "0.4.6" -#define LIBAVCODEC_BUILD 4616 -#define LIBAVCODEC_BUILD_STR "4616" +#define LIBAVCODEC_BUILD 4617 +#define LIBAVCODEC_BUILD_STR "4617" enum CodecID { CODEC_ID_NONE, @@ -258,7 +258,11 @@ uint8_t *dr_buffer[3]; int dr_stride; void *dr_opaque_frame; - void (*get_buffer_callback)(struct AVCodecContext *c, int width, int height, int pict_type); + void (*get_buffer_callback)(struct AVCodecContext *c, int width, int height, int pict_type); + + int has_b_frames; // is 1 if the decoded stream contains b frames + int dr_uvstride; + int dr_ip_buffer_count; //FIXME this should be reordered after kabis API is finished ... /* @@ -282,13 +286,13 @@ ul_res0,ul_res1,ul_res2,ul_res3,ul_res4,ul_res5, ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12; unsigned int - ui_res0,ui_res1,ui_res2,ui_res3,ui_res4,ui_res5; + ui_res0,ui_res1,ui_res2; unsigned short int us_res0,us_res1,us_res2,us_res3,us_res4,us_res5, us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12; unsigned char uc_res0,uc_res1,uc_res2,uc_res3,uc_res4,uc_res5, - uc_res6,uc_res7,uc_res8,uc_res9,uc_res10,uc_res11,uc_res12; + uc_res6,uc_res7,uc_res8,uc_res9,uc_res10,uc_res11,uc_res12; } AVCodecContext; typedef struct AVCodec { @@ -299,7 +303,7 @@ int (*init)(AVCodecContext *); int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data); int (*close)(AVCodecContext *); - int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, UINT8 *buf, int buf_size); int capabilities; struct AVCodec *next;
--- a/h263dec.c Mon Jul 15 07:43:22 2002 +0000 +++ b/h263dec.c Mon Jul 15 14:15:10 2002 +0000 @@ -154,6 +154,7 @@ } else { ret = h263_decode_picture_header(s); } + avctx->has_b_frames= s->has_b_frames; /* After H263 & mpeg4 header decode we have the height, width,*/ @@ -432,8 +433,8 @@ pict->data[2] = s->last_picture[2]; } pict->linesize[0] = s->linesize; - pict->linesize[1] = s->linesize / 2; - pict->linesize[2] = s->linesize / 2; + pict->linesize[1] = s->uvlinesize; + pict->linesize[2] = s->uvlinesize; avctx->quality = s->qscale;
--- a/mpeg12.c Mon Jul 15 07:43:22 2002 +0000 +++ b/mpeg12.c Mon Jul 15 14:15:10 2002 +0000 @@ -1505,8 +1505,8 @@ pict->data[1] = picture[1]; pict->data[2] = picture[2]; pict->linesize[0] = s->linesize; - pict->linesize[1] = s->linesize / 2; - pict->linesize[2] = s->linesize / 2; + pict->linesize[1] = s->uvlinesize; + pict->linesize[2] = s->uvlinesize; return 1; } else { return 0; @@ -1546,7 +1546,7 @@ } s->width = width; s->height = height; - s->has_b_frames = 1; + avctx->has_b_frames= s->has_b_frames = 1; s->avctx = avctx; avctx->width = width; avctx->height = height; @@ -1642,8 +1642,8 @@ picture->data[1] = s2->next_picture[1]; picture->data[2] = s2->next_picture[2]; picture->linesize[0] = s2->linesize; - picture->linesize[1] = s2->linesize / 2; - picture->linesize[2] = s2->linesize / 2; + picture->linesize[1] = s2->uvlinesize; + picture->linesize[2] = s2->uvlinesize; *data_size = sizeof(AVPicture); } return 0;
--- a/mpegvideo.c Mon Jul 15 07:43:22 2002 +0000 +++ b/mpegvideo.c Mon Jul 15 14:15:10 2002 +0000 @@ -145,7 +145,8 @@ s->mb_height = (s->height + 15) / 16; s->mb_num = s->mb_width * s->mb_height; if(!(s->flags&CODEC_FLAG_DR1)){ - s->linesize = s->mb_width * 16 + 2 * EDGE_WIDTH; + s->linesize = s->mb_width * 16 + 2 * EDGE_WIDTH; + s->uvlinesize = s->mb_width * 8 + EDGE_WIDTH; for(i=0;i<3;i++) { int w, h, shift, pict_start; @@ -153,8 +154,8 @@ w = s->linesize; h = s->mb_height * 16 + 2 * EDGE_WIDTH; shift = (i == 0) ? 0 : 1; - c_size = (w >> shift) * (h >> shift); - pict_start = (w >> shift) * (EDGE_WIDTH >> shift) + (EDGE_WIDTH >> shift); + c_size = (s->linesize>>shift) * (h >> shift); + pict_start = (s->linesize>>shift) * (EDGE_WIDTH >> shift) + (EDGE_WIDTH >> shift); CHECKED_ALLOCZ(pict, c_size) s->last_picture_base[i] = pict; @@ -175,6 +176,7 @@ if(i>0) memset(s->aux_picture_base[i], 128, c_size); } } + s->ip_buffer_count= 2; } CHECKED_ALLOCZ(s->edge_emu_buffer, (s->width+32)*2*17); @@ -622,7 +624,9 @@ int i; avctx->get_buffer_callback(avctx, s->width, s->height, s->pict_type); - s->linesize= avctx->dr_stride; + s->linesize = avctx->dr_stride; + s->uvlinesize= avctx->dr_uvstride; + s->ip_buffer_count= avctx->dr_ip_buffer_count; } if (s->pict_type == B_TYPE) { @@ -664,13 +668,13 @@ if (s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4 || s->divx_version>=500){ draw_edges(s->current_picture[0], s->linesize, s->mb_width*16, s->mb_height*16, EDGE_WIDTH); - draw_edges(s->current_picture[1], s->linesize/2, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2); - draw_edges(s->current_picture[2], s->linesize/2, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2); + draw_edges(s->current_picture[1], s->uvlinesize, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2); + draw_edges(s->current_picture[2], s->uvlinesize, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2); }else{ /* mpeg4? / opendivx / xvid */ draw_edges(s->current_picture[0], s->linesize, s->width, s->height, EDGE_WIDTH); - draw_edges(s->current_picture[1], s->linesize/2, s->width/2, s->height/2, EDGE_WIDTH/2); - draw_edges(s->current_picture[2], s->linesize/2, s->width/2, s->height/2, EDGE_WIDTH/2); + draw_edges(s->current_picture[1], s->uvlinesize, s->width/2, s->height/2, EDGE_WIDTH/2); + draw_edges(s->current_picture[2], s->uvlinesize, s->width/2, s->height/2, EDGE_WIDTH/2); } } emms_c(); @@ -715,8 +719,8 @@ //printf("index:%d type:%d strides: %d %d\n", index, s->input_pict_type, pict->linesize[0], s->linesize); if( (index==0 || (s->flags&CODEC_FLAG_INPUT_PRESERVED)) && pict->linesize[0] == s->linesize - && pict->linesize[1] == s->linesize>>1 - && pict->linesize[2] == s->linesize>>1){ + && pict->linesize[1] == s->uvlinesize + && pict->linesize[2] == s->uvlinesize){ //printf("ptr\n"); for(i=0; i<3; i++){ s->coded_order[index].picture[i]= pict->data[i]; @@ -870,7 +874,7 @@ int h) { UINT8 *ptr; - int offset, src_x, src_y, linesize; + int offset, src_x, src_y, linesize, uvlinesize; int motion_x, motion_y; if(s->real_sprite_warping_points>1) printf("more than 1 warp point isnt supported\n"); @@ -888,6 +892,7 @@ motion_y =0; linesize = s->linesize; + uvlinesize = s->uvlinesize; ptr = ref_picture[0] + (src_y * linesize) + src_x + src_offset; dest_y+=dest_offset; @@ -907,11 +912,11 @@ if (src_y == s->height>>1) motion_y =0; - offset = (src_y * linesize>>1) + src_x + (src_offset>>1); + offset = (src_y * uvlinesize) + src_x + (src_offset>>1); ptr = ref_picture[1] + offset; - gmc1(dest_cb + (dest_offset>>1), ptr, linesize>>1, h>>1, motion_x&15, motion_y&15, s->no_rounding); + gmc1(dest_cb + (dest_offset>>1), ptr, uvlinesize, h>>1, motion_x&15, motion_y&15, s->no_rounding); ptr = ref_picture[2] + offset; - gmc1(dest_cr + (dest_offset>>1), ptr, linesize>>1, h>>1, motion_x&15, motion_y&15, s->no_rounding); + gmc1(dest_cr + (dest_offset>>1), ptr, uvlinesize, h>>1, motion_x&15, motion_y&15, s->no_rounding); return; } @@ -1047,20 +1052,20 @@ if (src_y == (height >> 1)) dxy &= ~2; - offset = (src_y * (linesize >> 1)) + src_x + (src_offset >> 1); + offset = (src_y * s->uvlinesize) + src_x + (src_offset >> 1); ptr = ref_picture[1] + offset; if(emu){ - emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); + emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); ptr= s->edge_emu_buffer; } - pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); + pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1); ptr = ref_picture[2] + offset; if(emu){ - emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); + emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); ptr= s->edge_emu_buffer; } - pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); + pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1); } static inline void qpel_motion(MpegEncContext *s, @@ -1126,20 +1131,20 @@ if (src_y == (height >> 1)) dxy &= ~2; - offset = (src_y * (linesize >> 1)) + src_x + (src_offset >> 1); + offset = (src_y * s->uvlinesize) + src_x + (src_offset >> 1); ptr = ref_picture[1] + offset; if(emu){ - emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); + emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); ptr= s->edge_emu_buffer; } - pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); + pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1); ptr = ref_picture[2] + offset; if(emu){ - emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); + emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); ptr= s->edge_emu_buffer; } - pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); + pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1); } @@ -1246,24 +1251,24 @@ if (src_y == s->height/2) dxy &= ~2; - offset = (src_y * (s->linesize >> 1)) + src_x; + offset = (src_y * (s->uvlinesize)) + src_x; ptr = ref_picture[1] + offset; if(s->flags&CODEC_FLAG_EMU_EDGE){ if(src_x<0 || src_y<0 || src_x + (dxy &1) + 8 > s->width >>1 || src_y + (dxy>>1) + 8 > s->height>>1){ - emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize>>1, 9, 9, src_x, src_y, s->width>>1, s->height>>1); + emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->width>>1, s->height>>1); ptr= s->edge_emu_buffer; emu=1; } } - pix_op[dxy](dest_cb, ptr, s->linesize >> 1, 8); + pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8); ptr = ref_picture[2] + offset; if(emu){ - emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize>>1, 9, 9, src_x, src_y, s->width>>1, s->height>>1); + emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->width>>1, s->height>>1); ptr= s->edge_emu_buffer; } - pix_op[dxy](dest_cr, ptr, s->linesize >> 1, 8); + pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8); break; case MV_TYPE_FIELD: if (s->picture_structure == PICT_FRAME) { @@ -1425,19 +1430,22 @@ UINT8 *mbskip_ptr = &s->mbskip_table[mb_xy]; if (s->mb_skiped) { s->mb_skiped = 0; + + (*mbskip_ptr) ++; /* indicate that this time we skiped it */ + if(*mbskip_ptr >99) *mbskip_ptr= 99; + /* if previous was skipped too, then nothing to do ! skip only during decoding as we might trash the buffers during encoding a bit */ - if (*mbskip_ptr != 0 && !s->encoding) + if (*mbskip_ptr >= s->ip_buffer_count && !s->encoding) goto the_end; - *mbskip_ptr = 1; /* indicate that this time we skiped it */ } else { *mbskip_ptr = 0; /* not skipped */ } } dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize) + mb_x * 16; - dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; - dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; + dest_cb = s->current_picture[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; + dest_cr = s->current_picture[2] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; if (s->interlaced_dct) { dct_linesize = s->linesize * 2; @@ -1482,8 +1490,8 @@ add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); if(!(s->flags&CODEC_FLAG_GRAY)){ - add_dequant_dct(s, block[4], 4, dest_cb, s->linesize >> 1); - add_dequant_dct(s, block[5], 5, dest_cr, s->linesize >> 1); + add_dequant_dct(s, block[4], 4, dest_cb, s->uvlinesize); + add_dequant_dct(s, block[5], 5, dest_cr, s->uvlinesize); } } else { add_dct(s, block[0], 0, dest_y, dct_linesize); @@ -1492,8 +1500,8 @@ add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); if(!(s->flags&CODEC_FLAG_GRAY)){ - add_dct(s, block[4], 4, dest_cb, s->linesize >> 1); - add_dct(s, block[5], 5, dest_cr, s->linesize >> 1); + add_dct(s, block[4], 4, dest_cb, s->uvlinesize); + add_dct(s, block[5], 5, dest_cr, s->uvlinesize); } } } else { @@ -1504,8 +1512,8 @@ put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); if(!(s->flags&CODEC_FLAG_GRAY)){ - put_dct(s, block[4], 4, dest_cb, s->linesize >> 1); - put_dct(s, block[5], 5, dest_cr, s->linesize >> 1); + put_dct(s, block[4], 4, dest_cb, s->uvlinesize); + put_dct(s, block[5], 5, dest_cr, s->uvlinesize); } } } @@ -1620,8 +1628,8 @@ int wrap_y, wrap_c; dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize ) + mb_x * 16; - dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; - dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; + dest_cb = s->current_picture[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; + dest_cr = s->current_picture[2] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; wrap_y = s->linesize; wrap_c = wrap_y>>1; ptr_y = s->new_picture[0] + (mb_y * 16 * wrap_y) + mb_x * 16; @@ -2566,8 +2574,8 @@ for(y=0; y<8; y++){ int x; for(x=0; x<8; x++){ - dest_cb[x + y*(s->linesize>>1)]= dcb/8; - dest_cr[x + y*(s->linesize>>1)]= dcr/8; + dest_cb[x + y*(s->uvlinesize)]= dcb/8; + dest_cr[x + y*(s->uvlinesize)]= dcr/8; } } } @@ -2622,8 +2630,8 @@ for(; mb_y>=0 && mb_y>=s->resync_mb_y; mb_y--){ for(; mb_x>=0; mb_x--){ uint8_t *dest_y = s->current_picture[0] + (mb_y * 16* s->linesize ) + mb_x * 16; - uint8_t *dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; - uint8_t *dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; + uint8_t *dest_cb = s->current_picture[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; + uint8_t *dest_cr = s->current_picture[2] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; int mb_x_backup= s->mb_x; //FIXME pass xy to mpeg_motion int mb_y_backup= s->mb_y; s->mb_x=mb_x;
--- a/mpegvideo.h Mon Jul 15 07:43:22 2002 +0000 +++ b/mpegvideo.h Mon Jul 15 14:15:10 2002 +0000 @@ -132,6 +132,7 @@ int mb_width, mb_height; /* number of MBs horizontally & vertically */ int mb_num; /* number of MBs of a picture */ int linesize; /* line size, in bytes, may be different from width */ + int uvlinesize; /* line size, for chroma in bytes, may be different from width */ UINT8 *new_picture[3]; /* picture to be compressed */ UINT8 *picture_buffer[REORDER_BUFFER_SIZE][3]; /* internal buffers used for reordering of input pictures */ int picture_buffer_index; @@ -145,6 +146,7 @@ UINT8 *current_picture[3]; /* buffer to store the decompressed current picture */ void *last_dr_opaque; void *next_dr_opaque; + int ip_buffer_count; /* number of buffers, currently only >2 if dr1 is used */ int num_available_buffers; /* is 0 at the start & after seeking, after the first I frame its 1 after next I/P 2 */ int last_dc[3]; /* last DC values for MPEG1 */ INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */ @@ -340,6 +342,8 @@ int quant_precision; int quarter_sample; /* 1->qpel, 0->half pel ME/MC */ int scalability; + int hierachy_type; + int enhancement_type; int new_pred; int reduced_res_vop; int aspect_ratio_info;
--- a/msmpeg4.c Mon Jul 15 07:43:22 2002 +0000 +++ b/msmpeg4.c Mon Jul 15 14:15:10 2002 +0000 @@ -763,7 +763,7 @@ wrap= s->linesize; dest= s->current_picture[0] + (((n>>1) + 2*s->mb_y) * 8* wrap ) + ((n&1) + 2*s->mb_x) * 8; }else{ - wrap= s->linesize>>1; + wrap= s->uvlinesize; dest= s->current_picture[n-3] + (s->mb_y * 8 * wrap) + s->mb_x * 8; } if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
--- a/rv10.c Mon Jul 15 07:43:22 2002 +0000 +++ b/rv10.c Mon Jul 15 14:15:10 2002 +0000 @@ -487,8 +487,8 @@ pict->data[1] = s->current_picture[1]; pict->data[2] = s->current_picture[2]; pict->linesize[0] = s->linesize; - pict->linesize[1] = s->linesize / 2; - pict->linesize[2] = s->linesize / 2; + pict->linesize[1] = s->uvlinesize; + pict->linesize[2] = s->uvlinesize; avctx->quality = s->qscale; *data_size = sizeof(AVPicture);