Mercurial > libavcodec.hg
comparison utils.c @ 2756:d8874c8749ec libavcodec
subtitle codec type support
| author | bellard |
|---|---|
| date | Fri, 03 Jun 2005 13:59:38 +0000 |
| parents | 32336384162e |
| children | 2b37bcabe608 |
comparison
equal
deleted
inserted
replaced
| 2755:975074f04b95 | 2756:d8874c8749ec |
|---|---|
| 588 return ret; | 588 return ret; |
| 589 }else | 589 }else |
| 590 return 0; | 590 return 0; |
| 591 } | 591 } |
| 592 | 592 |
| 593 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, | |
| 594 const AVSubtitle *sub) | |
| 595 { | |
| 596 int ret; | |
| 597 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub); | |
| 598 avctx->frame_number++; | |
| 599 return ret; | |
| 600 } | |
| 601 | |
| 593 /** | 602 /** |
| 594 * decode a frame. | 603 * decode a frame. |
| 595 * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes | 604 * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes |
| 596 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end | 605 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end |
| 597 * @param buf_size the size of the buffer in bytes | 606 * @param buf_size the size of the buffer in bytes |
| 634 | 643 |
| 635 *frame_size_ptr= 0; | 644 *frame_size_ptr= 0; |
| 636 ret = avctx->codec->decode(avctx, samples, frame_size_ptr, | 645 ret = avctx->codec->decode(avctx, samples, frame_size_ptr, |
| 637 buf, buf_size); | 646 buf, buf_size); |
| 638 avctx->frame_number++; | 647 avctx->frame_number++; |
| 648 return ret; | |
| 649 } | |
| 650 | |
| 651 /* decode a subtitle message. return -1 if error, otherwise return the | |
| 652 *number of bytes used. If no subtitle could be decompressed, | |
| 653 *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ | |
| 654 int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, | |
| 655 int *got_sub_ptr, | |
| 656 const uint8_t *buf, int buf_size) | |
| 657 { | |
| 658 int ret; | |
| 659 | |
| 660 *got_sub_ptr = 0; | |
| 661 ret = avctx->codec->decode(avctx, sub, got_sub_ptr, | |
| 662 (uint8_t *)buf, buf_size); | |
| 663 if (*got_sub_ptr) | |
| 664 avctx->frame_number++; | |
| 639 return ret; | 665 return ret; |
| 640 } | 666 } |
| 641 | 667 |
| 642 int avcodec_close(AVCodecContext *avctx) | 668 int avcodec_close(AVCodecContext *avctx) |
| 643 { | 669 { |
| 806 break; | 832 break; |
| 807 case CODEC_TYPE_DATA: | 833 case CODEC_TYPE_DATA: |
| 808 snprintf(buf, buf_size, "Data: %s", codec_name); | 834 snprintf(buf, buf_size, "Data: %s", codec_name); |
| 809 bitrate = enc->bit_rate; | 835 bitrate = enc->bit_rate; |
| 810 break; | 836 break; |
| 837 case CODEC_TYPE_SUBTITLE: | |
| 838 snprintf(buf, buf_size, "Subtitle: %s", codec_name); | |
| 839 bitrate = enc->bit_rate; | |
| 840 break; | |
| 811 default: | 841 default: |
| 812 snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); | 842 snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); |
| 813 return; | 843 return; |
| 814 } | 844 } |
| 815 if (encode) { | 845 if (encode) { |
