comparison svq1.c @ 903:22ee74da2cd3 libavcodec

cleanup adding AVVideoFrame moving quality, pict_type, key_frame, qscale_table, ... to AVVideoFrame removing obsolete variables in AVCodecContext skiping of MBs in b frames correctly initalizing AVCodecContext picture buffer cleanup
author michaelni
date Wed, 04 Dec 2002 10:04:03 +0000
parents 058194d7ade6
children 3814e9115672
comparison
equal deleted inserted replaced
902:6acc8394960d 903:22ee74da2cd3
1061 UINT8 *buf, int buf_size) 1061 UINT8 *buf, int buf_size)
1062 { 1062 {
1063 MpegEncContext *s=avctx->priv_data; 1063 MpegEncContext *s=avctx->priv_data;
1064 uint8_t *current, *previous; 1064 uint8_t *current, *previous;
1065 int result, i, x, y, width, height; 1065 int result, i, x, y, width, height;
1066 AVPicture *pict = data; 1066 AVVideoFrame *pict = data;
1067 1067
1068 /* initialize bit buffer */ 1068 /* initialize bit buffer */
1069 init_get_bits(&s->gb,buf,buf_size); 1069 init_get_bits(&s->gb,buf,buf_size);
1070 1070
1071 /* decode frame header */ 1071 /* decode frame header */
1082 src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i]; 1082 src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i];
1083 } 1083 }
1084 } 1084 }
1085 1085
1086 result = svq1_decode_frame_header (&s->gb, s); 1086 result = svq1_decode_frame_header (&s->gb, s);
1087
1088 if(MPV_frame_start(s, avctx) < 0)
1089 return -1;
1090 1087
1091 if (result != 0) 1088 if (result != 0)
1092 { 1089 {
1093 #ifdef DEBUG_SVQ1 1090 #ifdef DEBUG_SVQ1
1094 printf("Error in svq1_decode_frame_header %i\n",result); 1091 printf("Error in svq1_decode_frame_header %i\n",result);
1095 #endif 1092 #endif
1096 return result; 1093 return result;
1097 } 1094 }
1098 1095
1099 if(avctx->hurry_up && s->pict_type==B_TYPE) return buf_size; 1096 if(avctx->hurry_up && s->pict_type==B_TYPE) return buf_size;
1097
1098 if(MPV_frame_start(s, avctx) < 0)
1099 return -1;
1100 1100
1101 /* decode y, u and v components */ 1101 /* decode y, u and v components */
1102 for (i=0; i < 3; i++) { 1102 for (i=0; i < 3; i++) {
1103 int linesize; 1103 int linesize;
1104 if (i == 0) { 1104 if (i == 0) {
1110 width = (s->width/4+15)&~15; 1110 width = (s->width/4+15)&~15;
1111 height = (s->height/4+15)&~15; 1111 height = (s->height/4+15)&~15;
1112 linesize= s->uvlinesize; 1112 linesize= s->uvlinesize;
1113 } 1113 }
1114 1114
1115 current = s->current_picture[i]; 1115 current = s->current_picture.data[i];
1116 1116
1117 if(s->pict_type==B_TYPE){ 1117 if(s->pict_type==B_TYPE){
1118 previous = s->next_picture[i]; 1118 previous = s->next_picture.data[i];
1119 }else{ 1119 }else{
1120 previous = s->last_picture[i]; 1120 previous = s->last_picture.data[i];
1121 } 1121 }
1122 1122
1123 if (s->pict_type == I_TYPE) { 1123 if (s->pict_type == I_TYPE) {
1124 /* keyframe */ 1124 /* keyframe */
1125 for (y=0; y < height; y+=16) { 1125 for (y=0; y < height; y+=16) {
1157 pmv[0].y = 0; 1157 pmv[0].y = 0;
1158 1158
1159 current += 16*linesize; 1159 current += 16*linesize;
1160 } 1160 }
1161 } 1161 }
1162 1162 }
1163 pict->data[i] = s->current_picture[i]; 1163
1164 pict->linesize[i] = linesize; 1164 *pict = *(AVVideoFrame*)&s->current_picture;
1165 } 1165
1166 1166
1167 *data_size=sizeof(AVPicture); 1167 MPV_frame_end(s);
1168
1169 *data_size=sizeof(AVVideoFrame);
1168 return buf_size; 1170 return buf_size;
1169 } 1171 }
1170 1172
1171 static int svq1_decode_init(AVCodecContext *avctx) 1173 static int svq1_decode_init(AVCodecContext *avctx)
1172 { 1174 {
1174 1176
1175 s->avctx = avctx; 1177 s->avctx = avctx;
1176 s->width = (avctx->width+3)&~3; 1178 s->width = (avctx->width+3)&~3;
1177 s->height = (avctx->height+3)&~3; 1179 s->height = (avctx->height+3)&~3;
1178 s->codec_id= avctx->codec->id; 1180 s->codec_id= avctx->codec->id;
1179 avctx->mbskip_table= s->mbskip_table;
1180 avctx->pix_fmt = PIX_FMT_YUV410P; 1181 avctx->pix_fmt = PIX_FMT_YUV410P;
1181 avctx->has_b_frames= s->has_b_frames=1; // not true, but DP frames and these behave like unidirectional b frames 1182 avctx->has_b_frames= s->has_b_frames=1; // not true, but DP frames and these behave like unidirectional b frames
1182 s->flags= avctx->flags; 1183 s->flags= avctx->flags;
1183 if (MPV_common_init(s) < 0) return -1; 1184 if (MPV_common_init(s) < 0) return -1;
1184 return 0; 1185 return 0;