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.

674 lines
20KB

  1. /*
  2. * DV decoder
  3. * Copyright (c) 2002 Fabrice Bellard.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include "avcodec.h"
  20. #include "dsputil.h"
  21. #include "mpegvideo.h"
  22. #include "simple_idct.h"
  23. #define NTSC_FRAME_SIZE 120000
  24. #define PAL_FRAME_SIZE 144000
  25. #define TEX_VLC_BITS 9
  26. typedef struct DVVideoDecodeContext {
  27. AVCodecContext *avctx;
  28. GetBitContext gb;
  29. VLC *vlc;
  30. int sampling_411; /* 0 = 420, 1 = 411 */
  31. int width, height;
  32. UINT8 *current_picture[3]; /* picture structure */
  33. int linesize[3];
  34. DCTELEM block[5*6][64] __align8;
  35. UINT8 dv_zigzag[2][64];
  36. UINT8 idct_permutation[64];
  37. /* XXX: move it to static storage ? */
  38. UINT8 dv_shift[2][22][64];
  39. void (*idct_put[2])(UINT8 *dest, int line_size, DCTELEM *block);
  40. } DVVideoDecodeContext;
  41. #include "dvdata.h"
  42. static VLC dv_vlc;
  43. /* XXX: also include quantization */
  44. static RL_VLC_ELEM *dv_rl_vlc[1];
  45. static void dv_build_unquantize_tables(DVVideoDecodeContext *s)
  46. {
  47. int i, q, j;
  48. /* NOTE: max left shift is 6 */
  49. for(q = 0; q < 22; q++) {
  50. /* 88 unquant */
  51. for(i = 1; i < 64; i++) {
  52. /* 88 table */
  53. j = s->idct_permutation[i];
  54. s->dv_shift[0][q][j] =
  55. dv_quant_shifts[q][dv_88_areas[i]] + 1;
  56. }
  57. /* 248 unquant */
  58. for(i = 1; i < 64; i++) {
  59. /* 248 table */
  60. s->dv_shift[1][q][i] =
  61. dv_quant_shifts[q][dv_248_areas[i]] + 1;
  62. }
  63. }
  64. }
  65. static int dvvideo_decode_init(AVCodecContext *avctx)
  66. {
  67. DVVideoDecodeContext *s = avctx->priv_data;
  68. MpegEncContext s2;
  69. static int done;
  70. if (!done) {
  71. int i;
  72. done = 1;
  73. /* NOTE: as a trick, we use the fact the no codes are unused
  74. to accelerate the parsing of partial codes */
  75. init_vlc(&dv_vlc, TEX_VLC_BITS, NB_DV_VLC,
  76. dv_vlc_len, 1, 1, dv_vlc_bits, 2, 2);
  77. dv_rl_vlc[0] = av_malloc(dv_vlc.table_size * sizeof(RL_VLC_ELEM));
  78. for(i = 0; i < dv_vlc.table_size; i++){
  79. int code= dv_vlc.table[i][0];
  80. int len = dv_vlc.table[i][1];
  81. int level, run;
  82. if(len<0){ //more bits needed
  83. run= 0;
  84. level= code;
  85. } else if (code == (NB_DV_VLC - 1)) {
  86. /* EOB */
  87. run = 0;
  88. level = 256;
  89. } else {
  90. run= dv_vlc_run[code] + 1;
  91. level= dv_vlc_level[code];
  92. }
  93. dv_rl_vlc[0][i].len = len;
  94. dv_rl_vlc[0][i].level = level;
  95. dv_rl_vlc[0][i].run = run;
  96. }
  97. }
  98. /* ugly way to get the idct & scantable */
  99. /* XXX: fix it */
  100. memset(&s2, 0, sizeof(MpegEncContext));
  101. s2.avctx = avctx;
  102. if (DCT_common_init(&s2) < 0)
  103. return -1;
  104. s->idct_put[0] = s2.idct_put;
  105. memcpy(s->idct_permutation, s2.idct_permutation, 64);
  106. memcpy(s->dv_zigzag[0], s2.intra_scantable.permutated, 64);
  107. /* XXX: use MMX also for idct248 */
  108. s->idct_put[1] = simple_idct248_put;
  109. memcpy(s->dv_zigzag[1], dv_248_zigzag, 64);
  110. /* XXX: do it only for constant case */
  111. dv_build_unquantize_tables(s);
  112. return 0;
  113. }
  114. //#define VLC_DEBUG
  115. typedef struct BlockInfo {
  116. const UINT8 *shift_table;
  117. const UINT8 *scan_table;
  118. UINT8 pos; /* position in block */
  119. UINT8 eob_reached; /* true if EOB has been reached */
  120. UINT8 dct_mode;
  121. UINT8 partial_bit_count;
  122. UINT16 partial_bit_buffer;
  123. int shift_offset;
  124. } BlockInfo;
  125. /* block size in bits */
  126. static const UINT16 block_sizes[6] = {
  127. 112, 112, 112, 112, 80, 80
  128. };
  129. #ifndef ALT_BITSTREAM_READER
  130. #error only works with ALT_BITSTREAM_READER
  131. #endif
  132. /* decode ac coefs */
  133. static void dv_decode_ac(DVVideoDecodeContext *s,
  134. BlockInfo *mb, INT16 *block, int last_index)
  135. {
  136. int last_re_index;
  137. int shift_offset = mb->shift_offset;
  138. const UINT8 *scan_table = mb->scan_table;
  139. const UINT8 *shift_table = mb->shift_table;
  140. int pos = mb->pos;
  141. int level, pos1, sign, run;
  142. int partial_bit_count;
  143. OPEN_READER(re, &s->gb);
  144. #ifdef VLC_DEBUG
  145. printf("start\n");
  146. #endif
  147. /* if we must parse a partial vlc, we do it here */
  148. partial_bit_count = mb->partial_bit_count;
  149. if (partial_bit_count > 0) {
  150. UINT8 buf[4];
  151. UINT32 v;
  152. int l, l1;
  153. GetBitContext gb1;
  154. /* build the dummy bit buffer */
  155. l = 16 - partial_bit_count;
  156. UPDATE_CACHE(re, &s->gb);
  157. #ifdef VLC_DEBUG
  158. printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16));
  159. #endif
  160. v = (mb->partial_bit_buffer << l) | SHOW_UBITS(re, &s->gb, l);
  161. buf[0] = v >> 8;
  162. buf[1] = v;
  163. #ifdef VLC_DEBUG
  164. printf("v=%04x cnt=%d %04x\n",
  165. v, partial_bit_count, (mb->partial_bit_buffer << l));
  166. #endif
  167. /* try to read the codeword */
  168. init_get_bits(&gb1, buf, 4);
  169. {
  170. OPEN_READER(re1, &gb1);
  171. UPDATE_CACHE(re1, &gb1);
  172. GET_RL_VLC(level, run, re1, &gb1, dv_rl_vlc[0],
  173. TEX_VLC_BITS, 2);
  174. l = re1_index;
  175. CLOSE_READER(re1, &gb1);
  176. }
  177. #ifdef VLC_DEBUG
  178. printf("****run=%d level=%d size=%d\n", run, level, l);
  179. #endif
  180. /* compute codeword length */
  181. l1 = (level != 256 && level != 0);
  182. /* if too long, we cannot parse */
  183. l -= partial_bit_count;
  184. if ((re_index + l + l1) > last_index)
  185. return;
  186. /* skip read bits */
  187. last_re_index = 0; /* avoid warning */
  188. re_index += l;
  189. /* by definition, if we can read the vlc, all partial bits
  190. will be read (otherwise we could have read the vlc before) */
  191. mb->partial_bit_count = 0;
  192. UPDATE_CACHE(re, &s->gb);
  193. goto handle_vlc;
  194. }
  195. /* get the AC coefficients until last_index is reached */
  196. for(;;) {
  197. UPDATE_CACHE(re, &s->gb);
  198. #ifdef VLC_DEBUG
  199. printf("%2d: bits=%04x index=%d\n",
  200. pos, SHOW_UBITS(re, &s->gb, 16), re_index);
  201. #endif
  202. last_re_index = re_index;
  203. GET_RL_VLC(level, run, re, &s->gb, dv_rl_vlc[0],
  204. TEX_VLC_BITS, 2);
  205. handle_vlc:
  206. #ifdef VLC_DEBUG
  207. printf("run=%d level=%d\n", run, level);
  208. #endif
  209. if (level == 256) {
  210. if (re_index > last_index) {
  211. cannot_read:
  212. /* put position before read code */
  213. re_index = last_re_index;
  214. mb->eob_reached = 0;
  215. break;
  216. }
  217. /* EOB */
  218. mb->eob_reached = 1;
  219. break;
  220. } else if (level != 0) {
  221. if ((re_index + 1) > last_index)
  222. goto cannot_read;
  223. sign = SHOW_SBITS(re, &s->gb, 1);
  224. level = (level ^ sign) - sign;
  225. LAST_SKIP_BITS(re, &s->gb, 1);
  226. pos += run;
  227. /* error */
  228. if (pos >= 64) {
  229. goto read_error;
  230. }
  231. pos1 = scan_table[pos];
  232. level = level << (shift_table[pos1] + shift_offset);
  233. block[pos1] = level;
  234. // printf("run=%d level=%d shift=%d\n", run, level, shift_table[pos1]);
  235. } else {
  236. if (re_index > last_index)
  237. goto cannot_read;
  238. /* level is zero: means run without coding. No
  239. sign is coded */
  240. pos += run;
  241. /* error */
  242. if (pos >= 64) {
  243. read_error:
  244. #if defined(VLC_DEBUG) || 1
  245. printf("error pos=%d\n", pos);
  246. #endif
  247. /* for errors, we consider the eob is reached */
  248. mb->eob_reached = 1;
  249. break;
  250. }
  251. }
  252. }
  253. CLOSE_READER(re, &s->gb);
  254. mb->pos = pos;
  255. }
  256. static inline void bit_copy(PutBitContext *pb, GetBitContext *gb, int bits_left)
  257. {
  258. while (bits_left >= 16) {
  259. put_bits(pb, 16, get_bits(gb, 16));
  260. bits_left -= 16;
  261. }
  262. if (bits_left > 0) {
  263. put_bits(pb, bits_left, get_bits(gb, bits_left));
  264. }
  265. }
  266. /* mb_x and mb_y are in units of 8 pixels */
  267. static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
  268. UINT8 *buf_ptr1,
  269. const UINT16 *mb_pos_ptr)
  270. {
  271. int quant, dc, dct_mode, class1, j;
  272. int mb_index, mb_x, mb_y, v, last_index;
  273. DCTELEM *block, *block1;
  274. int c_offset, bits_left;
  275. UINT8 *y_ptr;
  276. BlockInfo mb_data[5 * 6], *mb, *mb1;
  277. void (*idct_put)(UINT8 *dest, int line_size, DCTELEM *block);
  278. UINT8 *buf_ptr;
  279. PutBitContext pb, vs_pb;
  280. UINT8 mb_bit_buffer[80 + 4]; /* allow some slack */
  281. int mb_bit_count;
  282. UINT8 vs_bit_buffer[5 * 80 + 4]; /* allow some slack */
  283. int vs_bit_count;
  284. memset(s->block, 0, sizeof(s->block));
  285. /* pass 1 : read DC and AC coefficients in blocks */
  286. buf_ptr = buf_ptr1;
  287. block1 = &s->block[0][0];
  288. mb1 = mb_data;
  289. init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80, NULL, NULL);
  290. vs_bit_count = 0;
  291. for(mb_index = 0; mb_index < 5; mb_index++) {
  292. /* skip header */
  293. quant = buf_ptr[3] & 0x0f;
  294. buf_ptr += 4;
  295. init_put_bits(&pb, mb_bit_buffer, 80, NULL, NULL);
  296. mb_bit_count = 0;
  297. mb = mb1;
  298. block = block1;
  299. for(j = 0;j < 6; j++) {
  300. /* NOTE: size is not important here */
  301. init_get_bits(&s->gb, buf_ptr, 14);
  302. /* get the dc */
  303. dc = get_bits(&s->gb, 9);
  304. dc = (dc << (32 - 9)) >> (32 - 9);
  305. dct_mode = get_bits1(&s->gb);
  306. mb->dct_mode = dct_mode;
  307. mb->scan_table = s->dv_zigzag[dct_mode];
  308. class1 = get_bits(&s->gb, 2);
  309. mb->shift_offset = (class1 == 3);
  310. mb->shift_table = s->dv_shift[dct_mode]
  311. [quant + dv_quant_offset[class1]];
  312. dc = dc << 2;
  313. /* convert to unsigned because 128 is not added in the
  314. standard IDCT */
  315. dc += 1024;
  316. block[0] = dc;
  317. last_index = block_sizes[j];
  318. buf_ptr += last_index >> 3;
  319. mb->pos = 0;
  320. mb->partial_bit_count = 0;
  321. dv_decode_ac(s, mb, block, last_index);
  322. /* write the remaining bits in a new buffer only if the
  323. block is finished */
  324. bits_left = last_index - s->gb.index;
  325. if (mb->eob_reached) {
  326. mb->partial_bit_count = 0;
  327. mb_bit_count += bits_left;
  328. bit_copy(&pb, &s->gb, bits_left);
  329. } else {
  330. /* should be < 16 bits otherwise a codeword could have
  331. been parsed */
  332. mb->partial_bit_count = bits_left;
  333. mb->partial_bit_buffer = get_bits(&s->gb, bits_left);
  334. }
  335. block += 64;
  336. mb++;
  337. }
  338. flush_put_bits(&pb);
  339. /* pass 2 : we can do it just after */
  340. #ifdef VLC_DEBUG
  341. printf("***pass 2 size=%d\n", mb_bit_count);
  342. #endif
  343. block = block1;
  344. mb = mb1;
  345. init_get_bits(&s->gb, mb_bit_buffer, 80);
  346. for(j = 0;j < 6; j++) {
  347. if (!mb->eob_reached && s->gb.index < mb_bit_count) {
  348. dv_decode_ac(s, mb, block, mb_bit_count);
  349. /* if still not finished, no need to parse other blocks */
  350. if (!mb->eob_reached) {
  351. /* we could not parse the current AC coefficient,
  352. so we add the remaining bytes */
  353. bits_left = mb_bit_count - s->gb.index;
  354. if (bits_left > 0) {
  355. mb->partial_bit_count += bits_left;
  356. mb->partial_bit_buffer =
  357. (mb->partial_bit_buffer << bits_left) |
  358. get_bits(&s->gb, bits_left);
  359. }
  360. goto next_mb;
  361. }
  362. }
  363. block += 64;
  364. mb++;
  365. }
  366. /* all blocks are finished, so the extra bytes can be used at
  367. the video segment level */
  368. bits_left = mb_bit_count - s->gb.index;
  369. vs_bit_count += bits_left;
  370. bit_copy(&vs_pb, &s->gb, bits_left);
  371. next_mb:
  372. mb1 += 6;
  373. block1 += 6 * 64;
  374. }
  375. /* we need a pass other the whole video segment */
  376. flush_put_bits(&vs_pb);
  377. #ifdef VLC_DEBUG
  378. printf("***pass 3 size=%d\n", vs_bit_count);
  379. #endif
  380. block = &s->block[0][0];
  381. mb = mb_data;
  382. init_get_bits(&s->gb, vs_bit_buffer, 5 * 80);
  383. for(mb_index = 0; mb_index < 5; mb_index++) {
  384. for(j = 0;j < 6; j++) {
  385. if (!mb->eob_reached) {
  386. #ifdef VLC_DEBUG
  387. printf("start %d:%d\n", mb_index, j);
  388. #endif
  389. dv_decode_ac(s, mb, block, vs_bit_count);
  390. }
  391. block += 64;
  392. mb++;
  393. }
  394. }
  395. /* compute idct and place blocks */
  396. block = &s->block[0][0];
  397. mb = mb_data;
  398. for(mb_index = 0; mb_index < 5; mb_index++) {
  399. v = *mb_pos_ptr++;
  400. mb_x = v & 0xff;
  401. mb_y = v >> 8;
  402. y_ptr = s->current_picture[0] + (mb_y * s->linesize[0] * 8) + (mb_x * 8);
  403. if (s->sampling_411)
  404. c_offset = (mb_y * s->linesize[1] * 8) + ((mb_x >> 2) * 8);
  405. else
  406. c_offset = ((mb_y >> 1) * s->linesize[1] * 8) + ((mb_x >> 1) * 8);
  407. for(j = 0;j < 6; j++) {
  408. idct_put = s->idct_put[mb->dct_mode];
  409. if (j < 4) {
  410. if (s->sampling_411 && mb_x < (704 / 8)) {
  411. /* NOTE: at end of line, the macroblock is handled as 420 */
  412. idct_put(y_ptr + (j * 8), s->linesize[0], block);
  413. } else {
  414. idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->linesize[0]),
  415. s->linesize[0], block);
  416. }
  417. } else {
  418. if (s->sampling_411 && mb_x >= (704 / 8)) {
  419. uint8_t pixels[64], *c_ptr, *c_ptr1, *ptr;
  420. int y, linesize;
  421. /* NOTE: at end of line, the macroblock is handled as 420 */
  422. idct_put(pixels, 8, block);
  423. linesize = s->linesize[6 - j];
  424. c_ptr = s->current_picture[6 - j] + c_offset;
  425. ptr = pixels;
  426. for(y = 0;y < 8; y++) {
  427. /* convert to 411P */
  428. c_ptr1 = c_ptr + linesize;
  429. c_ptr1[0] = c_ptr[0] = (ptr[0] + ptr[1]) >> 1;
  430. c_ptr1[1] = c_ptr[1] = (ptr[2] + ptr[3]) >> 1;
  431. c_ptr1[2] = c_ptr[2] = (ptr[4] + ptr[5]) >> 1;
  432. c_ptr1[3] = c_ptr[3] = (ptr[6] + ptr[7]) >> 1;
  433. c_ptr += linesize * 2;
  434. ptr += 8;
  435. }
  436. } else {
  437. /* don't ask me why they inverted Cb and Cr ! */
  438. idct_put(s->current_picture[6 - j] + c_offset,
  439. s->linesize[6 - j], block);
  440. }
  441. }
  442. block += 64;
  443. mb++;
  444. }
  445. }
  446. }
  447. /* NOTE: exactly one frame must be given (120000 bytes for NTSC,
  448. 144000 bytes for PAL) */
  449. static int dvvideo_decode_frame(AVCodecContext *avctx,
  450. void *data, int *data_size,
  451. UINT8 *buf, int buf_size)
  452. {
  453. DVVideoDecodeContext *s = avctx->priv_data;
  454. int sct, dsf, apt, ds, nb_dif_segs, vs, size, width, height, i, packet_size;
  455. UINT8 *buf_ptr;
  456. const UINT16 *mb_pos_ptr;
  457. AVPicture *picture;
  458. /* parse id */
  459. init_get_bits(&s->gb, buf, buf_size);
  460. sct = get_bits(&s->gb, 3);
  461. if (sct != 0)
  462. return -1;
  463. skip_bits(&s->gb, 5);
  464. get_bits(&s->gb, 4); /* dsn (sequence number */
  465. get_bits(&s->gb, 1); /* fsc (channel number) */
  466. skip_bits(&s->gb, 3);
  467. get_bits(&s->gb, 8); /* dbn (diff block number 0-134) */
  468. dsf = get_bits(&s->gb, 1); /* 0 = NTSC 1 = PAL */
  469. if (get_bits(&s->gb, 1) != 0)
  470. return -1;
  471. skip_bits(&s->gb, 11);
  472. apt = get_bits(&s->gb, 3); /* apt */
  473. get_bits(&s->gb, 1); /* tf1 */
  474. skip_bits(&s->gb, 4);
  475. get_bits(&s->gb, 3); /* ap1 */
  476. get_bits(&s->gb, 1); /* tf2 */
  477. skip_bits(&s->gb, 4);
  478. get_bits(&s->gb, 3); /* ap2 */
  479. get_bits(&s->gb, 1); /* tf3 */
  480. skip_bits(&s->gb, 4);
  481. get_bits(&s->gb, 3); /* ap3 */
  482. /* init size */
  483. width = 720;
  484. if (dsf) {
  485. packet_size = PAL_FRAME_SIZE;
  486. height = 576;
  487. nb_dif_segs = 12;
  488. } else {
  489. packet_size = NTSC_FRAME_SIZE;
  490. height = 480;
  491. nb_dif_segs = 10;
  492. }
  493. /* NOTE: we only accept several full frames */
  494. if (buf_size < packet_size)
  495. return -1;
  496. /* XXX: is it correct to assume that 420 is always used in PAL
  497. mode ? */
  498. s->sampling_411 = !dsf;
  499. if (s->sampling_411)
  500. mb_pos_ptr = dv_place_411;
  501. else
  502. mb_pos_ptr = dv_place_420;
  503. /* (re)alloc picture if needed */
  504. if (s->width != width || s->height != height) {
  505. for(i=0;i<3;i++)
  506. av_freep(&s->current_picture[i]);
  507. for(i=0;i<3;i++) {
  508. size = width * height;
  509. s->linesize[i] = width;
  510. if (i >= 1) {
  511. size >>= 2;
  512. s->linesize[i] >>= s->sampling_411 ? 2 : 1;
  513. }
  514. s->current_picture[i] = av_malloc(size);
  515. if (!s->current_picture[i])
  516. return -1;
  517. }
  518. s->width = width;
  519. s->height = height;
  520. }
  521. /* for each DIF segment */
  522. buf_ptr = buf;
  523. for (ds = 0; ds < nb_dif_segs; ds++) {
  524. buf_ptr += 6 * 80; /* skip DIF segment header */
  525. for(vs = 0; vs < 27; vs++) {
  526. if ((vs % 3) == 0) {
  527. /* skip audio block */
  528. buf_ptr += 80;
  529. }
  530. dv_decode_video_segment(s, buf_ptr, mb_pos_ptr);
  531. buf_ptr += 5 * 80;
  532. mb_pos_ptr += 5;
  533. }
  534. }
  535. emms_c();
  536. /* return image */
  537. avctx->width = width;
  538. avctx->height = height;
  539. if (s->sampling_411)
  540. avctx->pix_fmt = PIX_FMT_YUV411P;
  541. else
  542. avctx->pix_fmt = PIX_FMT_YUV420P;
  543. if (dsf)
  544. avctx->frame_rate = 25 * FRAME_RATE_BASE;
  545. else
  546. avctx->frame_rate = 30 * FRAME_RATE_BASE;
  547. *data_size = sizeof(AVPicture);
  548. picture = data;
  549. for(i=0;i<3;i++) {
  550. picture->data[i] = s->current_picture[i];
  551. picture->linesize[i] = s->linesize[i];
  552. }
  553. return packet_size;
  554. }
  555. static int dvvideo_decode_end(AVCodecContext *avctx)
  556. {
  557. DVVideoDecodeContext *s = avctx->priv_data;
  558. int i;
  559. for(i=0;i<3;i++)
  560. av_freep(&s->current_picture[i]);
  561. return 0;
  562. }
  563. AVCodec dvvideo_decoder = {
  564. "dvvideo",
  565. CODEC_TYPE_VIDEO,
  566. CODEC_ID_DVVIDEO,
  567. sizeof(DVVideoDecodeContext),
  568. dvvideo_decode_init,
  569. NULL,
  570. dvvideo_decode_end,
  571. dvvideo_decode_frame,
  572. 0,
  573. NULL
  574. };
  575. typedef struct DVAudioDecodeContext {
  576. AVCodecContext *avctx;
  577. GetBitContext gb;
  578. } DVAudioDecodeContext;
  579. static int dvaudio_decode_init(AVCodecContext *avctx)
  580. {
  581. // DVAudioDecodeContext *s = avctx->priv_data;
  582. return 0;
  583. }
  584. /* NOTE: exactly one frame must be given (120000 bytes for NTSC,
  585. 144000 bytes for PAL) */
  586. static int dvaudio_decode_frame(AVCodecContext *avctx,
  587. void *data, int *data_size,
  588. UINT8 *buf, int buf_size)
  589. {
  590. // DVAudioDecodeContext *s = avctx->priv_data;
  591. return buf_size;
  592. }
  593. static int dvaudio_decode_end(AVCodecContext *avctx)
  594. {
  595. // DVAudioDecodeContext *s = avctx->priv_data;
  596. return 0;
  597. }
  598. AVCodec dvaudio_decoder = {
  599. "dvaudio",
  600. CODEC_TYPE_AUDIO,
  601. CODEC_ID_DVAUDIO,
  602. sizeof(DVAudioDecodeContext),
  603. dvaudio_decode_init,
  604. NULL,
  605. dvaudio_decode_end,
  606. dvaudio_decode_frame,
  607. 0,
  608. NULL
  609. };