Browse code

remove duplicated find_frame_end() code move codec specific code from parser.c -> <codecname>.c as far as its easily possible

Originally committed as revision 3087 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2004/04/29 23:21:33
Showing 6 changed files
... ...
@@ -306,8 +306,7 @@ static int decode_slice(MpegEncContext *s){
306 306
  * finds the end of the current frame in the bitstream.
307 307
  * @return the position of the first byte of the next frame, or -1
308 308
  */
309
-static int mpeg4_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
310
-    ParseContext *pc= &s->parse_context;
309
+int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
311 310
     int vop_found, i;
312 311
     uint32_t state;
313 312
     
... ...
@@ -326,23 +325,25 @@ static int mpeg4_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
326 326
         }
327 327
     }
328 328
 
329
-    if(vop_found){    
330
-      for(; i<buf_size; i++){
331
-        state= (state<<8) | buf[i];
332
-        if((state&0xFFFFFF00) == 0x100){
333
-            pc->frame_start_found=0;
334
-            pc->state=-1; 
335
-            return i-3;
329
+    if(vop_found){
330
+        /* EOF considered as end of frame */
331
+        if (buf_size == 0)
332
+            return 0;
333
+        for(; i<buf_size; i++){
334
+            state= (state<<8) | buf[i];
335
+            if((state&0xFFFFFF00) == 0x100){
336
+                pc->frame_start_found=0;
337
+                pc->state=-1; 
338
+                return i-3;
339
+            }
336 340
         }
337
-      }
338 341
     }
339 342
     pc->frame_start_found= vop_found;
340 343
     pc->state= state;
341 344
     return END_NOT_FOUND;
342 345
 }
343 346
 
344
-static int h263_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
345
-    ParseContext *pc= &s->parse_context;
347
+static int h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
346 348
     int vop_found, i;
347 349
     uint32_t state;
348 350
     
... ...
@@ -377,6 +378,27 @@ static int h263_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
377 377
     return END_NOT_FOUND;
378 378
 }
379 379
 
380
+static int h263_parse(AVCodecParserContext *s,
381
+                           AVCodecContext *avctx,
382
+                           uint8_t **poutbuf, int *poutbuf_size, 
383
+                           const uint8_t *buf, int buf_size)
384
+{
385
+    ParseContext *pc = s->priv_data;
386
+    int next;
387
+    
388
+    next= h263_find_frame_end(pc, buf, buf_size);
389
+
390
+    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
391
+        *poutbuf = NULL;
392
+        *poutbuf_size = 0;
393
+        return buf_size;
394
+    }
395
+
396
+    *poutbuf = (uint8_t *)buf;
397
+    *poutbuf_size = buf_size;
398
+    return next;
399
+}
400
+
380 401
 int ff_h263_decode_frame(AVCodecContext *avctx, 
381 402
                              void *data, int *data_size,
382 403
                              uint8_t *buf, int buf_size)
... ...
@@ -414,15 +436,15 @@ uint64_t time= rdtsc();
414 414
         int next;
415 415
         
416 416
         if(s->codec_id==CODEC_ID_MPEG4){
417
-            next= mpeg4_find_frame_end(s, buf, buf_size);
417
+            next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
418 418
         }else if(s->codec_id==CODEC_ID_H263){
419
-            next= h263_find_frame_end(s, buf, buf_size);
419
+            next= h263_find_frame_end(&s->parse_context, buf, buf_size);
420 420
         }else{
421 421
             av_log(s->avctx, AV_LOG_ERROR, "this codec doesnt support truncated bitstreams\n");
422 422
             return -1;
423 423
         }
424 424
         
425
-        if( ff_combine_frame(s, next, &buf, &buf_size) < 0 )
425
+        if( ff_combine_frame(&s->parse_context, next, &buf, &buf_size) < 0 )
426 426
             return buf_size;
427 427
     }
428 428
 
... ...
@@ -843,3 +865,11 @@ AVCodec flv_decoder = {
843 843
     ff_h263_decode_frame,
844 844
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1
845 845
 };
846
+
847
+AVCodecParser h263_parser = {
848
+    { CODEC_ID_H263 },
849
+    sizeof(ParseContext),
850
+    NULL,
851
+    h263_parse,
852
+    ff_parse_close,
853
+};
... ...
@@ -5520,8 +5520,7 @@ static inline int decode_picture_parameter_set(H264Context *h){
5520 5520
  * finds the end of the current frame in the bitstream.
5521 5521
  * @return the position of the first byte of the next frame, or -1
5522 5522
  */
5523
-static int find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
5524
-    ParseContext *pc= &s->parse_context;
5523
+static int find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
5525 5524
     int i;
5526 5525
     uint32_t state;
5527 5526
 //printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]);
... ...
@@ -5544,6 +5543,27 @@ static int find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
5544 5544
     return END_NOT_FOUND;
5545 5545
 }
5546 5546
 
5547
+static int h264_parse(AVCodecParserContext *s,
5548
+                      AVCodecContext *avctx,
5549
+                      uint8_t **poutbuf, int *poutbuf_size, 
5550
+                      const uint8_t *buf, int buf_size)
5551
+{
5552
+    ParseContext *pc = s->priv_data;
5553
+    int next;
5554
+    
5555
+    next= find_frame_end(pc, buf, buf_size);
5556
+
5557
+    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
5558
+        *poutbuf = NULL;
5559
+        *poutbuf_size = 0;
5560
+        return buf_size;
5561
+    }
5562
+
5563
+    *poutbuf = (uint8_t *)buf;
5564
+    *poutbuf_size = buf_size;
5565
+    return next;
5566
+}
5567
+
5547 5568
 static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
5548 5569
     MpegEncContext * const s = &h->s;
5549 5570
     AVCodecContext * const avctx= s->avctx;
... ...
@@ -5701,9 +5721,9 @@ static int decode_frame(AVCodecContext *avctx,
5701 5701
     }
5702 5702
     
5703 5703
     if(s->flags&CODEC_FLAG_TRUNCATED){
5704
-        int next= find_frame_end(s, buf, buf_size);
5704
+        int next= find_frame_end(&s->parse_context, buf, buf_size);
5705 5705
         
5706
-        if( ff_combine_frame(s, next, &buf, &buf_size) < 0 )
5706
+        if( ff_combine_frame(&s->parse_context, next, &buf, &buf_size) < 0 )
5707 5707
             return buf_size;
5708 5708
 //printf("next:%d buf_size:%d last_index:%d\n", next, buf_size, s->parse_context.last_index);
5709 5709
     }
... ...
@@ -5970,4 +5990,12 @@ AVCodec h264_decoder = {
5970 5970
     /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
5971 5971
 };
5972 5972
 
5973
+AVCodecParser h264_parser = {
5974
+    { CODEC_ID_H264 },
5975
+    sizeof(ParseContext),
5976
+    NULL,
5977
+    h264_parse,
5978
+    ff_parse_close,
5979
+};
5980
+
5973 5981
 #include "svq3.c"
... ...
@@ -2715,8 +2715,8 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
2715 2715
  * finds the end of the current frame in the bitstream.
2716 2716
  * @return the position of the first byte of the next frame, or -1
2717 2717
  */
2718
-static int mpeg1_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
2719
-    ParseContext *pc= &s->parse_context;
2718
+int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
2719
+{
2720 2720
     int i;
2721 2721
     uint32_t state;
2722 2722
     
... ...
@@ -2735,6 +2735,9 @@ static int mpeg1_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
2735 2735
     }
2736 2736
     
2737 2737
     if(pc->frame_start_found){
2738
+        /* EOF considered as end of frame */
2739
+        if (buf_size == 0)
2740
+            return 0;
2738 2741
         for(; i<buf_size; i++){
2739 2742
             state= (state<<8) | buf[i];
2740 2743
             if((state&0xFFFFFF00) == 0x100){
... ...
@@ -2775,9 +2778,9 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
2775 2775
     }
2776 2776
 
2777 2777
     if(s2->flags&CODEC_FLAG_TRUNCATED){
2778
-        int next= mpeg1_find_frame_end(s2, buf, buf_size);
2778
+        int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size);
2779 2779
         
2780
-        if( ff_combine_frame(s2, next, &buf, &buf_size) < 0 )
2780
+        if( ff_combine_frame(&s2->parse_context, next, &buf, &buf_size) < 0 )
2781 2781
             return buf_size;
2782 2782
     }    
2783 2783
     
... ...
@@ -3698,64 +3698,6 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
3698 3698
 
3699 3699
 #endif //CONFIG_ENCODERS
3700 3700
 
3701
-/**
3702
- * combines the (truncated) bitstream to a complete frame
3703
- * @returns -1 if no complete frame could be created
3704
- */
3705
-int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size){
3706
-    ParseContext *pc= &s->parse_context;
3707
-
3708
-#if 0
3709
-    if(pc->overread){
3710
-        printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
3711
-        printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
3712
-    }
3713
-#endif
3714
-
3715
-    /* copy overreaded byes from last frame into buffer */
3716
-    for(; pc->overread>0; pc->overread--){
3717
-        pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
3718
-    }
3719
-    
3720
-    pc->last_index= pc->index;
3721
-
3722
-    /* copy into buffer end return */
3723
-    if(next == END_NOT_FOUND){
3724
-        pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
3725
-
3726
-        memcpy(&pc->buffer[pc->index], *buf, *buf_size);
3727
-        pc->index += *buf_size;
3728
-        return -1;
3729
-    }
3730
-
3731
-    *buf_size=
3732
-    pc->overread_index= pc->index + next;
3733
-    
3734
-    /* append to buffer */
3735
-    if(pc->index){
3736
-        pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
3737
-
3738
-        memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
3739
-        pc->index = 0;
3740
-        *buf= pc->buffer;
3741
-    }
3742
-
3743
-    /* store overread bytes */
3744
-    for(;next < 0; next++){
3745
-        pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
3746
-        pc->overread++;
3747
-    }
3748
-
3749
-#if 0
3750
-    if(pc->overread){
3751
-        printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
3752
-        printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
3753
-    }
3754
-#endif
3755
-
3756
-    return 0;
3757
-}
3758
-
3759 3701
 void ff_mpeg_flush(AVCodecContext *avctx){
3760 3702
     int i;
3761 3703
     MpegEncContext *s = avctx->priv_data;
... ...
@@ -749,7 +749,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
749 749
 void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, 
750 750
                                     int src_x, int src_y, int w, int h);
751 751
 #define END_NOT_FOUND -100
752
-int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
752
+int ff_combine_frame(ParseContext *pc, int next, uint8_t **buf, int *buf_size);
753
+void ff_parse_close(AVCodecParserContext *s);
753 754
 void ff_mpeg_flush(AVCodecContext *avctx);
754 755
 void ff_print_debug_info(MpegEncContext *s, AVFrame *pict);
755 756
 void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix);
... ...
@@ -144,15 +144,8 @@ void av_parser_close(AVCodecParserContext *s)
144 144
 #define SLICE_MAX_START_CODE	0x000001af
145 145
 
146 146
 typedef struct ParseContext1{
147
-    uint8_t *buffer;
148
-    int index;
149
-    int last_index;
150
-    int buffer_size;
151
-    uint32_t state;             ///< contains the last few bytes in MSB order
152
-    int frame_start_found;
153
-    int overread;               ///< the number of bytes which where irreversibly read from the next frame
154
-    int overread_index;         ///< the index into ParseContext1.buffer of the overreaded bytes
155
-
147
+    ParseContext pc;
148
+/* XXX/FIXME PC1 vs. PC */
156 149
     /* MPEG2 specific */
157 150
     int frame_rate;
158 151
     int progressive_sequence;
... ...
@@ -167,7 +160,7 @@ typedef struct ParseContext1{
167 167
  * combines the (truncated) bitstream to a complete frame
168 168
  * @returns -1 if no complete frame could be created
169 169
  */
170
-static int ff_combine_frame1(ParseContext1 *pc, int next, uint8_t **buf, int *buf_size)
170
+int ff_combine_frame(ParseContext *pc, int next, uint8_t **buf, int *buf_size)
171 171
 {
172 172
 #if 0
173 173
     if(pc->overread){
... ...
@@ -220,48 +213,6 @@ static int ff_combine_frame1(ParseContext1 *pc, int next, uint8_t **buf, int *bu
220 220
     return 0;
221 221
 }
222 222
 
223
-/**
224
- * finds the end of the current frame in the bitstream.
225
- * @return the position of the first byte of the next frame, or -1
226
- */
227
-static int mpeg1_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
228
-{
229
-    int i;
230
-    uint32_t state;
231
-    
232
-    state= pc->state;
233
-    
234
-    i=0;
235
-    if(!pc->frame_start_found){
236
-        for(i=0; i<buf_size; i++){
237
-            state= (state<<8) | buf[i];
238
-            if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){
239
-                i++;
240
-                pc->frame_start_found=1;
241
-                break;
242
-            }
243
-        }
244
-    }
245
-    
246
-    if(pc->frame_start_found){
247
-        /* EOF considered as end of frame */
248
-        if (buf_size == 0)
249
-            return 0;
250
-        for(; i<buf_size; i++){
251
-            state= (state<<8) | buf[i];
252
-            if((state&0xFFFFFF00) == 0x100){
253
-                if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){
254
-                    pc->frame_start_found=0;
255
-                    pc->state=-1; 
256
-                    return i-3;
257
-                }
258
-            }
259
-        }
260
-    }        
261
-    pc->state= state;
262
-    return END_NOT_FOUND;
263
-}
264
-
265 223
 static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
266 224
 {
267 225
     const uint8_t *buf_ptr;
... ...
@@ -404,12 +355,13 @@ static int mpegvideo_parse(AVCodecParserContext *s,
404 404
                            uint8_t **poutbuf, int *poutbuf_size, 
405 405
                            const uint8_t *buf, int buf_size)
406 406
 {
407
-    ParseContext1 *pc = s->priv_data;
407
+    ParseContext1 *pc1 = s->priv_data;
408
+    ParseContext *pc= &pc1->pc;
408 409
     int next;
409 410
     
410
-    next= mpeg1_find_frame_end(pc, buf, buf_size);
411
+    next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
411 412
     
412
-    if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
413
+    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
413 414
         *poutbuf = NULL;
414 415
         *poutbuf_size = 0;
415 416
         return buf_size;
... ...
@@ -428,59 +380,23 @@ static int mpegvideo_parse(AVCodecParserContext *s,
428 428
     return next;
429 429
 }
430 430
 
431
-static void mpegvideo_parse_close(AVCodecParserContext *s)
431
+void ff_parse_close(AVCodecParserContext *s)
432 432
 {
433
-    ParseContext1 *pc = s->priv_data;
433
+    ParseContext *pc = s->priv_data;
434 434
 
435 435
     av_free(pc->buffer);
436
-    av_free(pc->enc);
437 436
 }
438 437
 
439
-/*************************/
440
-
441
-/**
442
- * finds the end of the current frame in the bitstream.
443
- * @return the position of the first byte of the next frame, or -1
444
- */
445
-static int mpeg4_find_frame_end(ParseContext1 *pc, 
446
-                                const uint8_t *buf, int buf_size)
438
+static void parse1_close(AVCodecParserContext *s)
447 439
 {
448
-    int vop_found, i;
449
-    uint32_t state;
450
-    
451
-    vop_found= pc->frame_start_found;
452
-    state= pc->state;
453
-    
454
-    i=0;
455
-    if(!vop_found){
456
-        for(i=0; i<buf_size; i++){
457
-            state= (state<<8) | buf[i];
458
-            if(state == 0x1B6){
459
-                i++;
460
-                vop_found=1;
461
-                break;
462
-            }
463
-        }
464
-    }
440
+    ParseContext1 *pc1 = s->priv_data;
465 441
 
466
-    if(vop_found){    
467
-        /* EOF considered as end of frame */
468
-        if (buf_size == 0)
469
-            return 0;
470
-        for(; i<buf_size; i++){
471
-            state= (state<<8) | buf[i];
472
-            if((state&0xFFFFFF00) == 0x100){
473
-                pc->frame_start_found=0;
474
-                pc->state=-1; 
475
-                return i-3;
476
-            }
477
-        }
478
-    }
479
-    pc->frame_start_found= vop_found;
480
-    pc->state= state;
481
-    return END_NOT_FOUND;
442
+    av_free(pc1->pc.buffer);
443
+    av_free(pc1->enc);
482 444
 }
483 445
 
446
+/*************************/
447
+
484 448
 /* used by parser */
485 449
 /* XXX: make it use less memory */
486 450
 static int av_mpeg4_decode_header(AVCodecParserContext *s1, 
... ...
@@ -526,12 +442,12 @@ static int mpeg4video_parse(AVCodecParserContext *s,
526 526
                            uint8_t **poutbuf, int *poutbuf_size, 
527 527
                            const uint8_t *buf, int buf_size)
528 528
 {
529
-    ParseContext1 *pc = s->priv_data;
529
+    ParseContext *pc = s->priv_data;
530 530
     int next;
531 531
     
532
-    next= mpeg4_find_frame_end(pc, buf, buf_size);
532
+    next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
533 533
 
534
-    if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
534
+    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
535 535
         *poutbuf = NULL;
536 536
         *poutbuf_size = 0;
537 537
         return buf_size;
... ...
@@ -545,116 +461,6 @@ static int mpeg4video_parse(AVCodecParserContext *s,
545 545
 
546 546
 /*************************/
547 547
 
548
-static int h263_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
549
-{
550
-    int vop_found, i;
551
-    uint32_t state;
552
-    
553
-    vop_found= pc->frame_start_found;
554
-    state= pc->state;
555
-    
556
-    i=0;
557
-    if(!vop_found){
558
-        for(i=0; i<buf_size; i++){
559
-            state= (state<<8) | buf[i];
560
-            if(state>>(32-22) == 0x20){
561
-                i++;
562
-                vop_found=1;
563
-                break;
564
-            }
565
-        }
566
-    }
567
-
568
-    if(vop_found){    
569
-      for(; i<buf_size; i++){
570
-        state= (state<<8) | buf[i];
571
-        if(state>>(32-22) == 0x20){
572
-            pc->frame_start_found=0;
573
-            pc->state=-1; 
574
-            return i-3;
575
-        }
576
-      }
577
-    }
578
-    pc->frame_start_found= vop_found;
579
-    pc->state= state;
580
-    
581
-    return END_NOT_FOUND;
582
-}
583
-
584
-static int h263_parse(AVCodecParserContext *s,
585
-                           AVCodecContext *avctx,
586
-                           uint8_t **poutbuf, int *poutbuf_size, 
587
-                           const uint8_t *buf, int buf_size)
588
-{
589
-    ParseContext1 *pc = s->priv_data;
590
-    int next;
591
-    
592
-    next= h263_find_frame_end(pc, buf, buf_size);
593
-
594
-    if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
595
-        *poutbuf = NULL;
596
-        *poutbuf_size = 0;
597
-        return buf_size;
598
-    }
599
-
600
-    *poutbuf = (uint8_t *)buf;
601
-    *poutbuf_size = buf_size;
602
-    return next;
603
-}
604
-
605
-/*************************/
606
-
607
-/**
608
- * finds the end of the current frame in the bitstream.
609
- * @return the position of the first byte of the next frame, or -1
610
- */
611
-static int h264_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
612
-{
613
-    int i;
614
-    uint32_t state;
615
-//printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]);
616
-//    mb_addr= pc->mb_addr - 1;
617
-    state= pc->state;
618
-    //FIXME this will fail with slices
619
-    for(i=0; i<buf_size; i++){
620
-        state= (state<<8) | buf[i];
621
-        if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){
622
-            if(pc->frame_start_found){
623
-                pc->state=-1; 
624
-                pc->frame_start_found= 0;
625
-                return i-3;
626
-            }
627
-            pc->frame_start_found= 1;
628
-        }
629
-    }
630
-    
631
-    pc->state= state;
632
-    return END_NOT_FOUND;
633
-}
634
-
635
-static int h264_parse(AVCodecParserContext *s,
636
-                      AVCodecContext *avctx,
637
-                      uint8_t **poutbuf, int *poutbuf_size, 
638
-                      const uint8_t *buf, int buf_size)
639
-{
640
-    ParseContext1 *pc = s->priv_data;
641
-    int next;
642
-    
643
-    next= h264_find_frame_end(pc, buf, buf_size);
644
-
645
-    if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
646
-        *poutbuf = NULL;
647
-        *poutbuf_size = 0;
648
-        return buf_size;
649
-    }
650
-
651
-    *poutbuf = (uint8_t *)buf;
652
-    *poutbuf_size = buf_size;
653
-    return next;
654
-}
655
-
656
-/*************************/
657
-
658 548
 typedef struct MpegAudioParseContext {
659 549
     uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE];	/* input buffer */
660 550
     uint8_t *inbuf_ptr;
... ...
@@ -913,7 +719,7 @@ AVCodecParser mpegvideo_parser = {
913 913
     sizeof(ParseContext1),
914 914
     NULL,
915 915
     mpegvideo_parse,
916
-    mpegvideo_parse_close,
916
+    parse1_close,
917 917
 };
918 918
 
919 919
 AVCodecParser mpeg4video_parser = {
... ...
@@ -921,23 +727,7 @@ AVCodecParser mpeg4video_parser = {
921 921
     sizeof(ParseContext1),
922 922
     mpeg4video_parse_init,
923 923
     mpeg4video_parse,
924
-    mpegvideo_parse_close,
925
-};
926
-
927
-AVCodecParser h263_parser = {
928
-    { CODEC_ID_H263 },
929
-    sizeof(ParseContext1),
930
-    NULL,
931
-    h263_parse,
932
-    mpegvideo_parse_close,
933
-};
934
-
935
-AVCodecParser h264_parser = {
936
-    { CODEC_ID_H264 },
937
-    sizeof(ParseContext1),
938
-    NULL,
939
-    h264_parse,
940
-    mpegvideo_parse_close,
924
+    parse1_close,
941 925
 };
942 926
 
943 927
 AVCodecParser mpegaudio_parser = {