]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/gsmdec.c
vble: remove vble_error_close
[ffmpeg] / libavcodec / gsmdec.c
index 57286c796f64a0611fd82ba744ffcf7aa4ff8590..1091745f4bda62cc9619cbff02200fe2790ebba5 100644 (file)
@@ -61,11 +61,15 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
     int frame_bytes = avctx->frame_size *
                       av_get_bytes_per_sample(avctx->sample_fmt);
 
-    if (*data_size < frame_bytes)
-        return -1;
-    *data_size = 0;
-    if(buf_size < avctx->block_align)
+    if (*data_size < frame_bytes) {
+        av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
+        return AVERROR(EINVAL);
+    }
+
+    if (buf_size < avctx->block_align) {
+        av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
         return AVERROR_INVALIDDATA;
+    }
 
     switch (avctx->codec_id) {
     case CODEC_ID_GSM:
@@ -85,6 +89,12 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
     return avctx->block_align;
 }
 
+static void gsm_flush(AVCodecContext *avctx)
+{
+    GSMContext *s = avctx->priv_data;
+    memset(s, 0, sizeof(*s));
+}
+
 AVCodec ff_gsm_decoder = {
     .name           = "gsm",
     .type           = AVMEDIA_TYPE_AUDIO,
@@ -92,6 +102,7 @@ AVCodec ff_gsm_decoder = {
     .priv_data_size = sizeof(GSMContext),
     .init           = gsm_init,
     .decode         = gsm_decode_frame,
+    .flush          = gsm_flush,
     .long_name = NULL_IF_CONFIG_SMALL("GSM"),
 };
 
@@ -102,5 +113,6 @@ AVCodec ff_gsm_ms_decoder = {
     .priv_data_size = sizeof(GSMContext),
     .init           = gsm_init,
     .decode         = gsm_decode_frame,
+    .flush          = gsm_flush,
     .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"),
 };