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