comparison mpeg12.c @ 6562:3f6b656f9f01 libavcodec

Factorize code a little.
author michael
date Thu, 03 Apr 2008 18:25:07 +0000
parents 48759bfbd073
children 100f8bc03e6b
comparison
equal deleted inserted replaced
6561:2883ce013c20 6562:3f6b656f9f01
2232 } 2232 }
2233 pc->state= state; 2233 pc->state= state;
2234 return END_NOT_FOUND; 2234 return END_NOT_FOUND;
2235 } 2235 }
2236 2236
2237 static int decode_chunks(AVCodecContext *avctx,
2238 AVFrame *picture, int *data_size,
2239 const uint8_t *buf, int buf_size);
2240
2237 /* handle buffering and image synchronisation */ 2241 /* handle buffering and image synchronisation */
2238 static int mpeg_decode_frame(AVCodecContext *avctx, 2242 static int mpeg_decode_frame(AVCodecContext *avctx,
2239 void *data, int *data_size, 2243 void *data, int *data_size,
2240 const uint8_t *buf, int buf_size) 2244 const uint8_t *buf, int buf_size)
2241 { 2245 {
2242 Mpeg1Context *s = avctx->priv_data; 2246 Mpeg1Context *s = avctx->priv_data;
2243 const uint8_t *buf_end;
2244 const uint8_t *buf_ptr;
2245 uint32_t start_code;
2246 int ret, input_size;
2247 AVFrame *picture = data; 2247 AVFrame *picture = data;
2248 MpegEncContext *s2 = &s->mpeg_enc_ctx; 2248 MpegEncContext *s2 = &s->mpeg_enc_ctx;
2249 dprintf(avctx, "fill_buffer\n"); 2249 dprintf(avctx, "fill_buffer\n");
2250 2250
2251 if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) { 2251 if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
2263 int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size); 2263 int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size);
2264 2264
2265 if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 ) 2265 if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
2266 return buf_size; 2266 return buf_size;
2267 } 2267 }
2268
2269 buf_ptr = buf;
2270 buf_end = buf + buf_size;
2271 2268
2272 #if 0 2269 #if 0
2273 if (s->repeat_field % 2 == 1) { 2270 if (s->repeat_field % 2 == 1) {
2274 s->repeat_field++; 2271 s->repeat_field++;
2275 //fprintf(stderr,"\nRepeating last frame: %d -> %d! pict: %d %d", avctx->frame_number-1, avctx->frame_number, 2272 //fprintf(stderr,"\nRepeating last frame: %d -> %d! pict: %d %d", avctx->frame_number-1, avctx->frame_number,
2284 if(s->mpeg_enc_ctx_allocated==0 && avctx->codec_tag == ff_get_fourcc("VCR2")) 2281 if(s->mpeg_enc_ctx_allocated==0 && avctx->codec_tag == ff_get_fourcc("VCR2"))
2285 vcr2_init_sequence(avctx); 2282 vcr2_init_sequence(avctx);
2286 2283
2287 s->slice_count= 0; 2284 s->slice_count= 0;
2288 2285
2286 return decode_chunks(avctx, picture, data_size, buf, buf_size);
2287 }
2288
2289 static int decode_chunks(AVCodecContext *avctx,
2290 AVFrame *picture, int *data_size,
2291 const uint8_t *buf, int buf_size)
2292 {
2293 Mpeg1Context *s = avctx->priv_data;
2294 MpegEncContext *s2 = &s->mpeg_enc_ctx;
2295 const uint8_t *buf_ptr = buf;
2296 const uint8_t *buf_end = buf + buf_size;
2297 int ret, input_size;
2298
2289 for(;;) { 2299 for(;;) {
2290 /* find start next code */ 2300 /* find start next code */
2291 start_code = -1; 2301 uint32_t start_code = -1;
2292 buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code); 2302 buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code);
2293 if (start_code > 0x1ff){ 2303 if (start_code > 0x1ff){
2294 if(s2->pict_type != FF_B_TYPE || avctx->skip_frame <= AVDISCARD_DEFAULT){ 2304 if(s2->pict_type != FF_B_TYPE || avctx->skip_frame <= AVDISCARD_DEFAULT){
2295 if(avctx->thread_count > 1){ 2305 if(avctx->thread_count > 1){
2296 int i; 2306 int i;