]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dvdsubdec.c
vp8: fix bilinear C code to work if src_stride != dst_stride.
[ffmpeg] / libavcodec / dvdsubdec.c
index f29d278d6da90947e55d7080ffb9e26a11fb3174..6b168cb352c0e19b6857f7368c0f24f9377ea12a 100644 (file)
 #include "avcodec.h"
 #include "get_bits.h"
 #include "dsputil.h"
-#include "libavutil/colorspace.h"
+#include "internal.h"
 
-//#define DEBUG
+#include "libavutil/attributes.h"
+#include "libavutil/colorspace.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/avstring.h"
 
 typedef struct DVDSubContext {
     uint32_t palette[16];
@@ -32,7 +35,7 @@ typedef struct DVDSubContext {
 
 static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values)
 {
-    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
     uint8_t r, g, b;
     int i, y, cb, cr;
     int r_add, g_add, b_add;
@@ -436,9 +439,6 @@ static int find_smallest_bounding_rectangle(AVSubtitle *s)
 }
 
 #ifdef DEBUG
-#undef fprintf
-#undef perror
-#undef exit
 static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h,
                      uint32_t *rgba_palette)
 {
@@ -499,7 +499,7 @@ static int dvdsub_decode(AVCodecContext *avctx,
     return buf_size;
 }
 
-static int dvdsub_init(AVCodecContext *avctx)
+static av_cold int dvdsub_init(AVCodecContext *avctx)
 {
     DVDSubContext *ctx = avctx->priv_data;
     char *data, *cur;
@@ -521,9 +521,16 @@ static int dvdsub_init(AVCodecContext *avctx)
             ctx->has_palette = 1;
             for (i = 0; i < 16; i++) {
                 ctx->palette[i] = strtoul(p, &p, 16);
-                while (*p == ',' || isspace(*p))
+                while (*p == ',' || av_isspace(*p))
                     p++;
             }
+        } else if (!strncmp("size:", cur, 5)) {
+            int w, h;
+            if (sscanf(cur + 5, "%dx%d", &w, &h) == 2) {
+               int ret = ff_set_dimensions(avctx, w, h);
+               if (ret < 0)
+                   return ret;
+            }
         }
         cur += strcspn(cur, "\n\r");
         cur += strspn(cur, "\n\r");
@@ -534,10 +541,10 @@ static int dvdsub_init(AVCodecContext *avctx)
 
 AVCodec ff_dvdsub_decoder = {
     .name           = "dvdsub",
+    .long_name      = NULL_IF_CONFIG_SMALL("DVD subtitles"),
     .type           = AVMEDIA_TYPE_SUBTITLE,
     .id             = AV_CODEC_ID_DVD_SUBTITLE,
     .priv_data_size = sizeof(DVDSubContext),
     .init           = dvdsub_init,
     .decode         = dvdsub_decode,
-    .long_name      = NULL_IF_CONFIG_SMALL("DVD subtitles"),
 };