You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

671 lines
20KB

  1. /*
  2. * DVD subtitle decoding
  3. * Copyright (c) 2005 Fabrice Bellard
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "avcodec.h"
  22. #include "get_bits.h"
  23. #include "dsputil.h"
  24. #include "internal.h"
  25. #include "libavutil/attributes.h"
  26. #include "libavutil/colorspace.h"
  27. #include "libavutil/opt.h"
  28. #include "libavutil/imgutils.h"
  29. #include "libavutil/avstring.h"
  30. typedef struct DVDSubContext
  31. {
  32. AVClass *class;
  33. uint32_t palette[16];
  34. char *palette_str;
  35. int has_palette;
  36. uint8_t colormap[4];
  37. uint8_t alpha[256];
  38. uint8_t *buf;
  39. int buf_size;
  40. #ifdef DEBUG
  41. int sub_id;
  42. #endif
  43. } DVDSubContext;
  44. static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values)
  45. {
  46. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  47. uint8_t r, g, b;
  48. int i, y, cb, cr;
  49. int r_add, g_add, b_add;
  50. for (i = num_values; i > 0; i--) {
  51. y = *ycbcr++;
  52. cr = *ycbcr++;
  53. cb = *ycbcr++;
  54. YUV_TO_RGB1_CCIR(cb, cr);
  55. YUV_TO_RGB2_CCIR(r, g, b, y);
  56. *rgba++ = (*alpha++ << 24) | (r << 16) | (g << 8) | b;
  57. }
  58. }
  59. static int decode_run_2bit(GetBitContext *gb, int *color)
  60. {
  61. unsigned int v, t;
  62. v = 0;
  63. for (t = 1; v < t && t <= 0x40; t <<= 2)
  64. v = (v << 4) | get_bits(gb, 4);
  65. *color = v & 3;
  66. if (v < 4) { /* Code for fill rest of line */
  67. return INT_MAX;
  68. }
  69. return v >> 2;
  70. }
  71. static int decode_run_8bit(GetBitContext *gb, int *color)
  72. {
  73. int len;
  74. int has_run = get_bits1(gb);
  75. if (get_bits1(gb))
  76. *color = get_bits(gb, 8);
  77. else
  78. *color = get_bits(gb, 2);
  79. if (has_run) {
  80. if (get_bits1(gb)) {
  81. len = get_bits(gb, 7);
  82. if (len == 0)
  83. len = INT_MAX;
  84. else
  85. len += 9;
  86. } else
  87. len = get_bits(gb, 3) + 2;
  88. } else
  89. len = 1;
  90. return len;
  91. }
  92. static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
  93. const uint8_t *buf, int start, int buf_size, int is_8bit)
  94. {
  95. GetBitContext gb;
  96. int bit_len;
  97. int x, y, len, color;
  98. uint8_t *d;
  99. bit_len = (buf_size - start) * 8;
  100. init_get_bits(&gb, buf + start, bit_len);
  101. x = 0;
  102. y = 0;
  103. d = bitmap;
  104. for(;;) {
  105. if (get_bits_count(&gb) > bit_len)
  106. return -1;
  107. if (is_8bit)
  108. len = decode_run_8bit(&gb, &color);
  109. else
  110. len = decode_run_2bit(&gb, &color);
  111. len = FFMIN(len, w - x);
  112. memset(d + x, color, len);
  113. x += len;
  114. if (x >= w) {
  115. y++;
  116. if (y >= h)
  117. break;
  118. d += linesize;
  119. x = 0;
  120. /* byte align */
  121. align_get_bits(&gb);
  122. }
  123. }
  124. return 0;
  125. }
  126. static void guess_palette(DVDSubContext* ctx,
  127. uint32_t *rgba_palette,
  128. uint32_t subtitle_color)
  129. {
  130. static const uint8_t level_map[4][4] = {
  131. // this configuration (full range, lowest to highest) in tests
  132. // seemed most common, so assume this
  133. {0xff},
  134. {0x00, 0xff},
  135. {0x00, 0x80, 0xff},
  136. {0x00, 0x55, 0xaa, 0xff},
  137. };
  138. uint8_t color_used[16] = { 0 };
  139. int nb_opaque_colors, i, level, j, r, g, b;
  140. uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha;
  141. if(ctx->has_palette) {
  142. for(i = 0; i < 4; i++)
  143. rgba_palette[i] = (ctx->palette[colormap[i]] & 0x00ffffff)
  144. | ((alpha[i] * 17U) << 24);
  145. return;
  146. }
  147. for(i = 0; i < 4; i++)
  148. rgba_palette[i] = 0;
  149. nb_opaque_colors = 0;
  150. for(i = 0; i < 4; i++) {
  151. if (alpha[i] != 0 && !color_used[colormap[i]]) {
  152. color_used[colormap[i]] = 1;
  153. nb_opaque_colors++;
  154. }
  155. }
  156. if (nb_opaque_colors == 0)
  157. return;
  158. j = 0;
  159. memset(color_used, 0, 16);
  160. for(i = 0; i < 4; i++) {
  161. if (alpha[i] != 0) {
  162. if (!color_used[colormap[i]]) {
  163. level = level_map[nb_opaque_colors][j];
  164. r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
  165. g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
  166. b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
  167. rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24);
  168. color_used[colormap[i]] = (i + 1);
  169. j++;
  170. } else {
  171. rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) |
  172. ((alpha[i] * 17) << 24);
  173. }
  174. }
  175. }
  176. }
  177. static void reset_rects(AVSubtitle *sub_header)
  178. {
  179. int i;
  180. if (sub_header->rects != NULL) {
  181. for (i = 0; i < sub_header->num_rects; i++) {
  182. av_freep(&sub_header->rects[i]->pict.data[0]);
  183. av_freep(&sub_header->rects[i]->pict.data[1]);
  184. av_freep(&sub_header->rects[i]);
  185. }
  186. av_freep(&sub_header->rects);
  187. sub_header->num_rects = 0;
  188. }
  189. }
  190. #define READ_OFFSET(a) (big_offsets ? AV_RB32(a) : AV_RB16(a))
  191. static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
  192. const uint8_t *buf, int buf_size)
  193. {
  194. int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
  195. int big_offsets, offset_size, is_8bit = 0;
  196. const uint8_t *yuv_palette = 0;
  197. uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha;
  198. int date;
  199. int i;
  200. int is_menu = 0;
  201. if (buf_size < 10)
  202. return -1;
  203. if (AV_RB16(buf) == 0) { /* HD subpicture with 4-byte offsets */
  204. big_offsets = 1;
  205. offset_size = 4;
  206. cmd_pos = 6;
  207. } else {
  208. big_offsets = 0;
  209. offset_size = 2;
  210. cmd_pos = 2;
  211. }
  212. cmd_pos = READ_OFFSET(buf + cmd_pos);
  213. if (cmd_pos < 0 || cmd_pos > buf_size - 2 - offset_size)
  214. return AVERROR(EAGAIN);
  215. while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
  216. date = AV_RB16(buf + cmd_pos);
  217. next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
  218. av_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
  219. cmd_pos, next_cmd_pos, date);
  220. pos = cmd_pos + 2 + offset_size;
  221. offset1 = -1;
  222. offset2 = -1;
  223. x1 = y1 = x2 = y2 = 0;
  224. while (pos < buf_size) {
  225. cmd = buf[pos++];
  226. av_dlog(NULL, "cmd=%02x\n", cmd);
  227. switch(cmd) {
  228. case 0x00:
  229. /* menu subpicture */
  230. is_menu = 1;
  231. break;
  232. case 0x01:
  233. /* set start date */
  234. sub_header->start_display_time = (date << 10) / 90;
  235. break;
  236. case 0x02:
  237. /* set end date */
  238. sub_header->end_display_time = (date << 10) / 90;
  239. break;
  240. case 0x03:
  241. /* set colormap */
  242. if ((buf_size - pos) < 2)
  243. goto fail;
  244. colormap[3] = buf[pos] >> 4;
  245. colormap[2] = buf[pos] & 0x0f;
  246. colormap[1] = buf[pos + 1] >> 4;
  247. colormap[0] = buf[pos + 1] & 0x0f;
  248. pos += 2;
  249. break;
  250. case 0x04:
  251. /* set alpha */
  252. if ((buf_size - pos) < 2)
  253. goto fail;
  254. alpha[3] = buf[pos] >> 4;
  255. alpha[2] = buf[pos] & 0x0f;
  256. alpha[1] = buf[pos + 1] >> 4;
  257. alpha[0] = buf[pos + 1] & 0x0f;
  258. pos += 2;
  259. av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
  260. break;
  261. case 0x05:
  262. case 0x85:
  263. if ((buf_size - pos) < 6)
  264. goto fail;
  265. x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
  266. x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
  267. y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
  268. y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
  269. if (cmd & 0x80)
  270. is_8bit = 1;
  271. av_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
  272. pos += 6;
  273. break;
  274. case 0x06:
  275. if ((buf_size - pos) < 4)
  276. goto fail;
  277. offset1 = AV_RB16(buf + pos);
  278. offset2 = AV_RB16(buf + pos + 2);
  279. av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
  280. pos += 4;
  281. break;
  282. case 0x86:
  283. if ((buf_size - pos) < 8)
  284. goto fail;
  285. offset1 = AV_RB32(buf + pos);
  286. offset2 = AV_RB32(buf + pos + 4);
  287. av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
  288. pos += 8;
  289. break;
  290. case 0x83:
  291. /* HD set palette */
  292. if ((buf_size - pos) < 768)
  293. goto fail;
  294. yuv_palette = buf + pos;
  295. pos += 768;
  296. break;
  297. case 0x84:
  298. /* HD set contrast (alpha) */
  299. if ((buf_size - pos) < 256)
  300. goto fail;
  301. for (i = 0; i < 256; i++)
  302. alpha[i] = 0xFF - buf[pos+i];
  303. pos += 256;
  304. break;
  305. case 0xff:
  306. goto the_end;
  307. default:
  308. av_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd);
  309. goto the_end;
  310. }
  311. }
  312. the_end:
  313. if (offset1 >= 0) {
  314. int w, h;
  315. uint8_t *bitmap;
  316. /* decode the bitmap */
  317. w = x2 - x1 + 1;
  318. if (w < 0)
  319. w = 0;
  320. h = y2 - y1;
  321. if (h < 0)
  322. h = 0;
  323. if (w > 0 && h > 0) {
  324. reset_rects(sub_header);
  325. bitmap = av_malloc(w * h);
  326. sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
  327. sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
  328. sub_header->num_rects = 1;
  329. sub_header->rects[0]->pict.data[0] = bitmap;
  330. decode_rle(bitmap, w * 2, w, (h + 1) / 2,
  331. buf, offset1, buf_size, is_8bit);
  332. decode_rle(bitmap + w, w * 2, w, h / 2,
  333. buf, offset2, buf_size, is_8bit);
  334. sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
  335. if (is_8bit) {
  336. if (yuv_palette == 0)
  337. goto fail;
  338. sub_header->rects[0]->nb_colors = 256;
  339. yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
  340. } else {
  341. sub_header->rects[0]->nb_colors = 4;
  342. guess_palette(ctx, (uint32_t*)sub_header->rects[0]->pict.data[1],
  343. 0xffff00);
  344. }
  345. sub_header->rects[0]->x = x1;
  346. sub_header->rects[0]->y = y1;
  347. sub_header->rects[0]->w = w;
  348. sub_header->rects[0]->h = h;
  349. sub_header->rects[0]->type = SUBTITLE_BITMAP;
  350. sub_header->rects[0]->pict.linesize[0] = w;
  351. sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0;
  352. }
  353. }
  354. if (next_cmd_pos < cmd_pos) {
  355. av_log(NULL, AV_LOG_ERROR, "Invalid command offset\n");
  356. break;
  357. }
  358. if (next_cmd_pos == cmd_pos)
  359. break;
  360. cmd_pos = next_cmd_pos;
  361. }
  362. if (sub_header->num_rects > 0)
  363. return is_menu;
  364. fail:
  365. reset_rects(sub_header);
  366. return -1;
  367. }
  368. static int is_transp(const uint8_t *buf, int pitch, int n,
  369. const uint8_t *transp_color)
  370. {
  371. int i;
  372. for(i = 0; i < n; i++) {
  373. if (!transp_color[*buf])
  374. return 0;
  375. buf += pitch;
  376. }
  377. return 1;
  378. }
  379. /* return 0 if empty rectangle, 1 if non empty */
  380. static int find_smallest_bounding_rectangle(AVSubtitle *s)
  381. {
  382. uint8_t transp_color[256] = { 0 };
  383. int y1, y2, x1, x2, y, w, h, i;
  384. uint8_t *bitmap;
  385. if (s->num_rects == 0 || s->rects == NULL || s->rects[0]->w <= 0 || s->rects[0]->h <= 0)
  386. return 0;
  387. for(i = 0; i < s->rects[0]->nb_colors; i++) {
  388. if ((((uint32_t*)s->rects[0]->pict.data[1])[i] >> 24) == 0)
  389. transp_color[i] = 1;
  390. }
  391. y1 = 0;
  392. while (y1 < s->rects[0]->h && is_transp(s->rects[0]->pict.data[0] + y1 * s->rects[0]->pict.linesize[0],
  393. 1, s->rects[0]->w, transp_color))
  394. y1++;
  395. if (y1 == s->rects[0]->h) {
  396. av_freep(&s->rects[0]->pict.data[0]);
  397. s->rects[0]->w = s->rects[0]->h = 0;
  398. return 0;
  399. }
  400. y2 = s->rects[0]->h - 1;
  401. while (y2 > 0 && is_transp(s->rects[0]->pict.data[0] + y2 * s->rects[0]->pict.linesize[0], 1,
  402. s->rects[0]->w, transp_color))
  403. y2--;
  404. x1 = 0;
  405. while (x1 < (s->rects[0]->w - 1) && is_transp(s->rects[0]->pict.data[0] + x1, s->rects[0]->pict.linesize[0],
  406. s->rects[0]->h, transp_color))
  407. x1++;
  408. x2 = s->rects[0]->w - 1;
  409. while (x2 > 0 && is_transp(s->rects[0]->pict.data[0] + x2, s->rects[0]->pict.linesize[0], s->rects[0]->h,
  410. transp_color))
  411. x2--;
  412. w = x2 - x1 + 1;
  413. h = y2 - y1 + 1;
  414. bitmap = av_malloc(w * h);
  415. if (!bitmap)
  416. return 1;
  417. for(y = 0; y < h; y++) {
  418. memcpy(bitmap + w * y, s->rects[0]->pict.data[0] + x1 + (y1 + y) * s->rects[0]->pict.linesize[0], w);
  419. }
  420. av_freep(&s->rects[0]->pict.data[0]);
  421. s->rects[0]->pict.data[0] = bitmap;
  422. s->rects[0]->pict.linesize[0] = w;
  423. s->rects[0]->w = w;
  424. s->rects[0]->h = h;
  425. s->rects[0]->x += x1;
  426. s->rects[0]->y += y1;
  427. return 1;
  428. }
  429. #ifdef DEBUG
  430. #undef fprintf
  431. #undef perror
  432. #undef exit
  433. static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h,
  434. uint32_t *rgba_palette)
  435. {
  436. int x, y, v;
  437. FILE *f;
  438. f = fopen(filename, "w");
  439. if (!f) {
  440. perror(filename);
  441. exit(1);
  442. }
  443. fprintf(f, "P6\n"
  444. "%d %d\n"
  445. "%d\n",
  446. w, h, 255);
  447. for(y = 0; y < h; y++) {
  448. for(x = 0; x < w; x++) {
  449. v = rgba_palette[bitmap[y * w + x]];
  450. putc((v >> 16) & 0xff, f);
  451. putc((v >> 8) & 0xff, f);
  452. putc((v >> 0) & 0xff, f);
  453. }
  454. }
  455. fclose(f);
  456. }
  457. #endif
  458. static int append_to_cached_buf(AVCodecContext *avctx,
  459. const uint8_t *buf, int buf_size)
  460. {
  461. DVDSubContext *ctx = avctx->priv_data;
  462. if (ctx->buf_size > 0xffff - buf_size) {
  463. av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "
  464. "too large SPU packets aborted.\n");
  465. av_freep(&ctx->buf);
  466. return AVERROR_INVALIDDATA;
  467. }
  468. ctx->buf = av_realloc(ctx->buf, ctx->buf_size + buf_size);
  469. if (!ctx->buf)
  470. return AVERROR(ENOMEM);
  471. memcpy(ctx->buf + ctx->buf_size, buf, buf_size);
  472. ctx->buf_size += buf_size;
  473. return 0;
  474. }
  475. static int dvdsub_decode(AVCodecContext *avctx,
  476. void *data, int *data_size,
  477. AVPacket *avpkt)
  478. {
  479. DVDSubContext *ctx = avctx->priv_data;
  480. const uint8_t *buf = avpkt->data;
  481. int buf_size = avpkt->size;
  482. AVSubtitle *sub = data;
  483. int is_menu;
  484. if (ctx->buf) {
  485. int ret = append_to_cached_buf(avctx, buf, buf_size);
  486. if (ret < 0) {
  487. *data_size = 0;
  488. return ret;
  489. }
  490. buf = ctx->buf;
  491. buf_size = ctx->buf_size;
  492. }
  493. is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
  494. if (is_menu == AVERROR(EAGAIN)) {
  495. *data_size = 0;
  496. return append_to_cached_buf(avctx, buf, buf_size);
  497. }
  498. if (is_menu < 0) {
  499. no_subtitle:
  500. *data_size = 0;
  501. return buf_size;
  502. }
  503. if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
  504. goto no_subtitle;
  505. #if defined(DEBUG)
  506. {
  507. char ppm_name[32];
  508. snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
  509. av_dlog(NULL, "start=%d ms end =%d ms\n",
  510. sub->start_display_time,
  511. sub->end_display_time);
  512. ppm_save(ppm_name, sub->rects[0]->pict.data[0],
  513. sub->rects[0]->w, sub->rects[0]->h, sub->rects[0]->pict.data[1]);
  514. }
  515. #endif
  516. av_freep(&ctx->buf);
  517. ctx->buf_size = 0;
  518. *data_size = 1;
  519. return buf_size;
  520. }
  521. static void parse_palette(DVDSubContext *ctx, char *p)
  522. {
  523. int i;
  524. ctx->has_palette = 1;
  525. for(i=0;i<16;i++) {
  526. ctx->palette[i] = strtoul(p, &p, 16);
  527. while(*p == ',' || av_isspace(*p))
  528. p++;
  529. }
  530. }
  531. static int dvdsub_parse_extradata(AVCodecContext *avctx)
  532. {
  533. DVDSubContext *ctx = (DVDSubContext*) avctx->priv_data;
  534. char *dataorig, *data;
  535. if (!avctx->extradata || !avctx->extradata_size)
  536. return 1;
  537. dataorig = data = av_malloc(avctx->extradata_size+1);
  538. if (!data)
  539. return AVERROR(ENOMEM);
  540. memcpy(data, avctx->extradata, avctx->extradata_size);
  541. data[avctx->extradata_size] = '\0';
  542. for(;;) {
  543. int pos = strcspn(data, "\n\r");
  544. if (pos==0 && *data==0)
  545. break;
  546. if (strncmp("palette:", data, 8) == 0) {
  547. parse_palette(ctx, data + 8);
  548. } else if (strncmp("size:", data, 5) == 0) {
  549. int w, h;
  550. if (sscanf(data + 5, "%dx%d", &w, &h) == 2) {
  551. int ret = ff_set_dimensions(avctx, w, h);
  552. if (ret < 0)
  553. return ret;
  554. }
  555. }
  556. data += pos;
  557. data += strspn(data, "\n\r");
  558. }
  559. av_free(dataorig);
  560. return 1;
  561. }
  562. static av_cold int dvdsub_init(AVCodecContext *avctx)
  563. {
  564. DVDSubContext *ctx = avctx->priv_data;
  565. int ret;
  566. if ((ret = dvdsub_parse_extradata(avctx)) < 0)
  567. return ret;
  568. if (ctx->palette_str)
  569. parse_palette(ctx, ctx->palette_str);
  570. if (ctx->has_palette) {
  571. int i;
  572. av_log(avctx, AV_LOG_DEBUG, "palette:");
  573. for(i=0;i<16;i++)
  574. av_log(avctx, AV_LOG_DEBUG, " 0x%06x", ctx->palette[i]);
  575. av_log(avctx, AV_LOG_DEBUG, "\n");
  576. }
  577. return 1;
  578. }
  579. static av_cold int dvdsub_close(AVCodecContext *avctx)
  580. {
  581. DVDSubContext *ctx = avctx->priv_data;
  582. av_freep(&ctx->buf);
  583. ctx->buf_size = 0;
  584. return 0;
  585. }
  586. #define OFFSET(field) offsetof(DVDSubContext, field)
  587. #define VD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
  588. static const AVOption options[] = {
  589. { "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD },
  590. { NULL }
  591. };
  592. static const AVClass dvdsub_class = {
  593. .class_name = "dvdsubdec",
  594. .item_name = av_default_item_name,
  595. .option = options,
  596. .version = LIBAVUTIL_VERSION_INT,
  597. };
  598. AVCodec ff_dvdsub_decoder = {
  599. .name = "dvdsub",
  600. .long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"),
  601. .type = AVMEDIA_TYPE_SUBTITLE,
  602. .id = AV_CODEC_ID_DVD_SUBTITLE,
  603. .priv_data_size = sizeof(DVDSubContext),
  604. .init = dvdsub_init,
  605. .decode = dvdsub_decode,
  606. .close = dvdsub_close,
  607. .priv_class = &dvdsub_class,
  608. };