int crop_top; ///< frame_cropping_rect_top_offset
int crop_bottom; ///< frame_cropping_rect_bottom_offset
int vui_parameters_present_flag;
- int sar_width;
- int sar_height;
+ AVRational sar;
short offset_for_ref_frame[256]; //FIXME dyn aloc?
}SPS;
if(h->sps.mb_aff){
//FIXME
+ topleft_xy = 0; /* avoid warning */
+ top_xy = 0; /* avoid warning */
+ topright_xy = 0; /* avoid warning */
}else{
topleft_xy = mb_xy-1 - s->mb_stride;
top_xy = mb_xy - s->mb_stride;
for(i=0; i<4; i++){
int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ];
if(status<0){
- fprintf(stderr, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
return -1;
} else if(status){
h->intra4x4_pred_mode_cache[scan8[0] + i]= status;
for(i=0; i<4; i++){
int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ];
if(status<0){
- fprintf(stderr, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
return -1;
} else if(status){
h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status;
if(!(h->top_samples_available&0x8000)){
mode= top[ mode ];
if(mode<0){
- fprintf(stderr, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
if(!(h->left_samples_available&0x8000)){
mode= left[ mode ];
if(mode<0){
- fprintf(stderr, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
init_pred_ptrs(h);
+ s->unrestricted_mv=1;
s->decode=1; //FIXME
}
if(index >= h->ref_count[list]){
- fprintf(stderr, "reference count overflow\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1;
}
const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
if(abs_diff_pic_num >= h->max_pic_num){
- fprintf(stderr, "abs_diff_pic_num overflow\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
return -1;
}
}
if(i < index){
- fprintf(stderr, "reference picture missing during reorder\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
}else if(i > index){
Picture tmp= h->ref_list[list][i];
}else if(reordering_of_pic_nums_idc==3)
break;
else{
- fprintf(stderr, "illegal reordering_of_pic_nums_idc\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
return -1;
}
}
int i;
if(s->avctx->debug&FF_DEBUG_MMCO)
- printf("remove short %d count %d\n", frame_num, h->short_ref_count);
+ av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
for(i=0; i<h->short_ref_count; i++){
Picture *pic= h->short_ref[i];
if(s->avctx->debug&FF_DEBUG_MMCO)
- printf("%d %d %p\n", i, pic->frame_num, pic);
+ av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
if(pic->frame_num == frame_num){
h->short_ref[i]= NULL;
memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i - 1)*sizeof(Picture*));
Picture *pic;
if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
- printf("no mmco here\n");
+ av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
for(i=0; i<mmco_count; i++){
if(s->avctx->debug&FF_DEBUG_MMCO)
- printf("mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index);
+ av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index);
switch(mmco[i].opcode){
case MMCO_SHORT2UNUSED:
pic= remove_short(h, s->current_picture_ptr->frame_num);
if(pic){
pic->reference=0;
- fprintf(stderr, "illegal short term buffer state detected\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
}
if(h->short_ref_count)
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
h->mmco[i].long_index= get_ue_golomb(&s->gb);
if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ h->mmco[i].long_index >= 16){
- fprintf(stderr, "illegal long ref in memory management control operation %d\n", opcode);
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
}
if(opcode > MMCO_LONG){
- fprintf(stderr, "illegal memory management control operation %d\n", opcode);
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
}
int first_mb_in_slice, pps_id;
int num_ref_idx_active_override_flag;
static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
- float new_aspect;
s->current_picture.reference= h->nal_ref_idc != 0;
h->slice_type= get_ue_golomb(&s->gb);
if(h->slice_type > 9){
- fprintf(stderr, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
}
if(h->slice_type > 4){
h->slice_type -= 5;
pps_id= get_ue_golomb(&s->gb);
if(pps_id>255){
- fprintf(stderr, "pps_id out of range\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
return -1;
}
h->pps= h->pps_buffer[pps_id];
if(h->pps.slice_group_count == 0){
- fprintf(stderr, "non existing PPS referenced\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "non existing PPS referenced\n");
return -1;
}
h->sps= h->sps_buffer[ h->pps.sps_id ];
if(h->sps.log2_max_frame_num == 0){
- fprintf(stderr, "non existing SPS referenced\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "non existing SPS referenced\n");
return -1;
}
else
s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom); //FIXME recheck
- if(s->aspected_height) //FIXME emms at end of slice ?
- new_aspect= h->sps.sar_width*s->width / (float)(s->height*h->sps.sar_height);
- else
- new_aspect=0;
-
if (s->context_initialized
- && ( s->width != s->avctx->width || s->height != s->avctx->height
- || ABS(new_aspect - s->avctx->aspect_ratio) > 0.001)) {
+ && ( s->width != s->avctx->width || s->height != s->avctx->height)) {
free_tables(h);
MPV_common_end(s);
}
s->avctx->width = s->width;
s->avctx->height = s->height;
- s->avctx->aspect_ratio= new_aspect;
+ s->avctx->sample_aspect_ratio= h->sps.sar;
}
if(first_mb_in_slice == 0){
}
if(h->nal_unit_type == NAL_IDR_SLICE){
- int idr_pic_id= get_ue_golomb(&s->gb);
+ get_ue_golomb(&s->gb); /* idr_pic_id */
}
if(h->sps.poc_type==0){
h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
- fprintf(stderr, "reference overflow\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
return -1;
}
}
s->qscale = h->pps.init_qp + get_se_golomb(&s->gb); //slice_qp_delta
//FIXME qscale / qp ... stuff
if(h->slice_type == SP_TYPE){
- int sp_for_switch_flag= get_bits1(&s->gb);
+ get_bits1(&s->gb); /* sp_for_switch_flag */
}
if(h->slice_type==SP_TYPE || h->slice_type == SI_TYPE){
- int slice_qs_delta= get_se_golomb(&s->gb);
+ get_se_golomb(&s->gb); /* slice_qs_delta */
}
if( h->pps.deblocking_filter_parameters_present ) {
#endif
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- printf("mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n",
first_mb_in_slice,
av_get_pict_type_char(h->slice_type),
pps_id, h->frame_num,
level_code= (prefix<<suffix_length) + get_bits(gb, 12); //part
if(suffix_length==0) level_code+=15; //FIXME doesnt make (much)sense
}else{
- fprintf(stderr, "prefix too large at %d %d\n", s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "prefix too large at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
if(zeros_left<0){
- fprintf(stderr, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->dsp.clear_blocks(h->mb); //FIXME avoid if allready clear (move after skip handlong?
tprintf("pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
-
+ cbp = 0; /* avoid warning. FIXME: find a solution without slowing
+ down the code */
if(h->slice_type != I_TYPE && h->slice_type != SI_TYPE){
if(s->mb_skip_run==-1)
s->mb_skip_run= get_ue_golomb(&s->gb);
assert(h->slice_type == I_TYPE);
decode_intra_mb:
if(mb_type > 25){
- fprintf(stderr, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
return -1;
}
partition_count=0;
for(i=0; i<4; i++){
h->sub_mb_type[i]= get_ue_golomb(&s->gb);
if(h->sub_mb_type[i] >=13){
- fprintf(stderr, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
return -1;
}
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
for(i=0; i<4; i++){
h->sub_mb_type[i]= get_ue_golomb(&s->gb);
if(h->sub_mb_type[i] >=4){
- fprintf(stderr, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
return -1;
}
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
if(!IS_INTRA16x16(mb_type)){
cbp= get_ue_golomb(&s->gb);
if(cbp > 47){
- fprintf(stderr, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y);
return -1;
}
dquant= get_se_golomb(&s->gb);
if( dquant > 25 || dquant < -26 ){
- fprintf(stderr, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y);
return -1;
}
}
}
}else{
- memset(&h->non_zero_count_cache[8], 0, 8*4); //FIXME stupid & slow
+ fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
}
}else{
for(i8x8=0; i8x8<4; i8x8++){
}
if(ret<0){
- fprintf(stderr, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
return -1;
if( aspect_ratio_info_present_flag ) {
aspect_ratio_idc= get_bits(&s->gb, 8);
if( aspect_ratio_idc == EXTENDED_SAR ) {
- sps->sar_width= get_bits(&s->gb, 16);
- sps->sar_height= get_bits(&s->gb, 16);
+ sps->sar.num= get_bits(&s->gb, 16);
+ sps->sar.den= get_bits(&s->gb, 16);
}else if(aspect_ratio_idc < 16){
- sps->sar_width= pixel_aspect[aspect_ratio_idc][0];
- sps->sar_height= pixel_aspect[aspect_ratio_idc][1];
+ sps->sar= pixel_aspect[aspect_ratio_idc];
}else{
- fprintf(stderr, "illegal aspect ratio\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal aspect ratio\n");
return -1;
}
}else{
- sps->sar_width=
- sps->sar_height= 0;
+ sps->sar.num=
+ sps->sar.den= 0;
}
// s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height);
#if 0
sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
}
if(sps->poc_type > 2){
- fprintf(stderr, "illegal POC type %d\n", sps->poc_type);
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
return -1;
}
sps->crop_top = get_ue_golomb(&s->gb);
sps->crop_bottom= get_ue_golomb(&s->gb);
if(sps->crop_left || sps->crop_top){
- fprintf(stderr, "insane croping not completly supported, this could look slightly wrong ...\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completly supported, this could look slightly wrong ...\n");
}
}else{
sps->crop_left =
decode_vui_parameters(h, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- printf("sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
pps->slice_group_count= get_ue_golomb(&s->gb) + 1;
if(pps->slice_group_count > 1 ){
pps->mb_slice_group_map_type= get_ue_golomb(&s->gb);
-fprintf(stderr, "FMO not supported\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n");
switch(pps->mb_slice_group_map_type){
case 0:
#if 0
pps->ref_count[0]= get_ue_golomb(&s->gb) + 1;
pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;
if(pps->ref_count[0] > 32 || pps->ref_count[1] > 32){
- fprintf(stderr, "reference overflow (pps)\n");
+ av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
return -1;
}
pps->redundant_pic_cnt_present = get_bits1(&s->gb);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- printf("pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n",
pps_id, pps->sps_id,
pps->cabac ? "CABAC" : "CAVLC",
pps->slice_group_count,
bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
if(s->avctx->debug&FF_DEBUG_STARTCODE){
- printf("NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length);
+ av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length);
}
buf_index += consumed;
int buf_index;
s->flags= avctx->flags;
+ s->flags2= avctx->flags2;
*data_size = 0;
}
#endif
if(!s->current_picture_ptr){
- fprintf(stderr, "error, NO frame\n");
+ av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n");
return -1;
}
*pict= *(AVFrame*)&s->current_picture; //FIXME
- ff_print_debug_info(s, s->current_picture_ptr);
+ ff_print_debug_info(s, pict);
assert(pict->data[0]);
//printf("out %d\n", (int)pict->data[0]);
#if 0 //?
dsputil_init(&dsp, &avctx);
- init_put_bits(&pb, temp, SIZE, NULL, NULL);
+ init_put_bits(&pb, temp, SIZE);
printf("testing unsigned exp golomb\n");
for(i=0; i<COUNT; i++){
START_TIMER
}
- init_put_bits(&pb, temp, SIZE, NULL, NULL);
+ init_put_bits(&pb, temp, SIZE);
printf("testing signed exp golomb\n");
for(i=0; i<COUNT; i++){
START_TIMER