summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2005-06-03 13:59:38 +0000
committerFabrice Bellard <fabrice@bellard.org>2005-06-03 13:59:38 +0000
commit240c1657dcd45adc0e63ef947b920919071ec1f7 (patch)
tree385f5f33871332a0c78cc3bc00aa5d74026536f3 /libavcodec/utils.c
parentc62112ff06f859c8c3ef096f859a0f5a941a1ce8 (diff)
subtitle codec type support
Originally committed as revision 4346 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index d1debfe402..a964a6fd46 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -590,6 +590,15 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
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 @@ int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
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 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
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;