Mercurial > libavcodec.hg
diff utils.c @ 2756:d8874c8749ec libavcodec
subtitle codec type support
author | bellard |
---|---|
date | Fri, 03 Jun 2005 13:59:38 +0000 |
parents | 32336384162e |
children | 2b37bcabe608 |
line wrap: on
line diff
--- a/utils.c Thu Jun 02 21:15:20 2005 +0000 +++ b/utils.c Fri Jun 03 13:59:38 2005 +0000 @@ -590,6 +590,15 @@ return 0; } +int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVSubtitle *sub) +{ + int ret; + ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub); + avctx->frame_number++; + return ret; +} + /** * decode a frame. * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes @@ -639,6 +648,23 @@ return ret; } +/* decode a subtitle message. return -1 if error, otherwise return the + *number of bytes used. If no subtitle could be decompressed, + *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ +int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + const uint8_t *buf, int buf_size) +{ + int ret; + + *got_sub_ptr = 0; + ret = avctx->codec->decode(avctx, sub, got_sub_ptr, + (uint8_t *)buf, buf_size); + if (*got_sub_ptr) + avctx->frame_number++; + return ret; +} + int avcodec_close(AVCodecContext *avctx) { if (avctx->codec->close) @@ -808,6 +834,10 @@ snprintf(buf, buf_size, "Data: %s", codec_name); bitrate = enc->bit_rate; break; + case CODEC_TYPE_SUBTITLE: + snprintf(buf, buf_size, "Subtitle: %s", codec_name); + bitrate = enc->bit_rate; + break; default: snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); return;