]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/utils.c
Add avsubtitle_free function.
[ffmpeg] / libavcodec / utils.c
index 902951137cc86dcb5f4a70b3b7974895044bf4e0..ced6b64c2936aca234bdfdac1348554f62f5e7b6 100644 (file)
@@ -506,6 +506,13 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
     }
     avctx->frame_number = 0;
     if(avctx->codec->init){
+        if(avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
+           avctx->codec->max_lowres < avctx->lowres){
+            av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
+                   avctx->codec->max_lowres);
+            goto free_and_end;
+        }
+
         ret = avctx->codec->init(avctx);
         if (ret < 0) {
             goto free_and_end;
@@ -682,6 +689,26 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
     return ret;
 }
 
+void avsubtitle_free(AVSubtitle *sub)
+{
+    int i;
+
+    for (i = 0; i < sub->num_rects; i++)
+    {
+        av_freep(sub->rects[i]->pict.data[0]);
+        av_freep(sub->rects[i]->pict.data[1]);
+        av_freep(sub->rects[i]->pict.data[2]);
+        av_freep(sub->rects[i]->pict.data[3]);
+        av_freep(sub->rects[i]->text);
+        av_freep(sub->rects[i]->ass);
+        av_freep(sub->rects[i]);
+    }
+
+    av_freep(sub->rects);
+
+    memset(sub, 0, sizeof(AVSubtitle));
+}
+
 av_cold int avcodec_close(AVCodecContext *avctx)
 {
     /* If there is a user-supplied mutex locking routine, call it. */