zmbv.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*
  2. * Zip Motion Blocks Video (ZMBV) decoder
  3. * Copyright (c) 2006 Konstantin Shishkov
  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. /**
  22. * @file libavcodec/zmbv.c
  23. * Zip Motion Blocks Video decoder
  24. */
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include "libavutil/intreadwrite.h"
  28. #include "avcodec.h"
  29. #include <zlib.h>
  30. #define ZMBV_KEYFRAME 1
  31. #define ZMBV_DELTAPAL 2
  32. enum ZmbvFormat {
  33. ZMBV_FMT_NONE = 0,
  34. ZMBV_FMT_1BPP = 1,
  35. ZMBV_FMT_2BPP = 2,
  36. ZMBV_FMT_4BPP = 3,
  37. ZMBV_FMT_8BPP = 4,
  38. ZMBV_FMT_15BPP = 5,
  39. ZMBV_FMT_16BPP = 6,
  40. ZMBV_FMT_24BPP = 7,
  41. ZMBV_FMT_32BPP = 8
  42. };
  43. /*
  44. * Decoder context
  45. */
  46. typedef struct ZmbvContext {
  47. AVCodecContext *avctx;
  48. AVFrame pic;
  49. int bpp;
  50. unsigned int decomp_size;
  51. uint8_t* decomp_buf;
  52. uint8_t pal[768];
  53. uint8_t *prev, *cur;
  54. int width, height;
  55. int fmt;
  56. int comp;
  57. int flags;
  58. int bw, bh, bx, by;
  59. int decomp_len;
  60. z_stream zstream;
  61. int (*decode_intra)(struct ZmbvContext *c);
  62. int (*decode_xor)(struct ZmbvContext *c);
  63. } ZmbvContext;
  64. /**
  65. * Decode XOR'ed frame - 8bpp version
  66. */
  67. static int zmbv_decode_xor_8(ZmbvContext *c)
  68. {
  69. uint8_t *src = c->decomp_buf;
  70. uint8_t *output, *prev;
  71. int8_t *mvec;
  72. int x, y;
  73. int d, dx, dy, bw2, bh2;
  74. int block;
  75. int i, j;
  76. int mx, my;
  77. output = c->cur;
  78. prev = c->prev;
  79. if(c->flags & ZMBV_DELTAPAL){
  80. for(i = 0; i < 768; i++)
  81. c->pal[i] ^= *src++;
  82. }
  83. mvec = (int8_t*)src;
  84. src += ((c->bx * c->by * 2 + 3) & ~3);
  85. block = 0;
  86. for(y = 0; y < c->height; y += c->bh) {
  87. bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
  88. for(x = 0; x < c->width; x += c->bw) {
  89. uint8_t *out, *tprev;
  90. d = mvec[block] & 1;
  91. dx = mvec[block] >> 1;
  92. dy = mvec[block + 1] >> 1;
  93. block += 2;
  94. bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
  95. /* copy block - motion vectors out of bounds are used to zero blocks */
  96. out = output + x;
  97. tprev = prev + x + dx + dy * c->width;
  98. mx = x + dx;
  99. my = y + dy;
  100. for(j = 0; j < bh2; j++){
  101. if((my + j < 0) || (my + j >= c->height)) {
  102. memset(out, 0, bw2);
  103. } else {
  104. for(i = 0; i < bw2; i++){
  105. if((mx + i < 0) || (mx + i >= c->width))
  106. out[i] = 0;
  107. else
  108. out[i] = tprev[i];
  109. }
  110. }
  111. out += c->width;
  112. tprev += c->width;
  113. }
  114. if(d) { /* apply XOR'ed difference */
  115. out = output + x;
  116. for(j = 0; j < bh2; j++){
  117. for(i = 0; i < bw2; i++)
  118. out[i] ^= *src++;
  119. out += c->width;
  120. }
  121. }
  122. }
  123. output += c->width * c->bh;
  124. prev += c->width * c->bh;
  125. }
  126. if(src - c->decomp_buf != c->decomp_len)
  127. av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
  128. return 0;
  129. }
  130. /**
  131. * Decode XOR'ed frame - 15bpp and 16bpp version
  132. */
  133. static int zmbv_decode_xor_16(ZmbvContext *c)
  134. {
  135. uint8_t *src = c->decomp_buf;
  136. uint16_t *output, *prev;
  137. int8_t *mvec;
  138. int x, y;
  139. int d, dx, dy, bw2, bh2;
  140. int block;
  141. int i, j;
  142. int mx, my;
  143. output = (uint16_t*)c->cur;
  144. prev = (uint16_t*)c->prev;
  145. mvec = (int8_t*)src;
  146. src += ((c->bx * c->by * 2 + 3) & ~3);
  147. block = 0;
  148. for(y = 0; y < c->height; y += c->bh) {
  149. bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
  150. for(x = 0; x < c->width; x += c->bw) {
  151. uint16_t *out, *tprev;
  152. d = mvec[block] & 1;
  153. dx = mvec[block] >> 1;
  154. dy = mvec[block + 1] >> 1;
  155. block += 2;
  156. bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
  157. /* copy block - motion vectors out of bounds are used to zero blocks */
  158. out = output + x;
  159. tprev = prev + x + dx + dy * c->width;
  160. mx = x + dx;
  161. my = y + dy;
  162. for(j = 0; j < bh2; j++){
  163. if((my + j < 0) || (my + j >= c->height)) {
  164. memset(out, 0, bw2 * 2);
  165. } else {
  166. for(i = 0; i < bw2; i++){
  167. if((mx + i < 0) || (mx + i >= c->width))
  168. out[i] = 0;
  169. else
  170. out[i] = tprev[i];
  171. }
  172. }
  173. out += c->width;
  174. tprev += c->width;
  175. }
  176. if(d) { /* apply XOR'ed difference */
  177. out = output + x;
  178. for(j = 0; j < bh2; j++){
  179. for(i = 0; i < bw2; i++) {
  180. out[i] ^= *((uint16_t*)src);
  181. src += 2;
  182. }
  183. out += c->width;
  184. }
  185. }
  186. }
  187. output += c->width * c->bh;
  188. prev += c->width * c->bh;
  189. }
  190. if(src - c->decomp_buf != c->decomp_len)
  191. av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
  192. return 0;
  193. }
  194. #ifdef ZMBV_ENABLE_24BPP
  195. /**
  196. * Decode XOR'ed frame - 24bpp version
  197. */
  198. static int zmbv_decode_xor_24(ZmbvContext *c)
  199. {
  200. uint8_t *src = c->decomp_buf;
  201. uint8_t *output, *prev;
  202. int8_t *mvec;
  203. int x, y;
  204. int d, dx, dy, bw2, bh2;
  205. int block;
  206. int i, j;
  207. int mx, my;
  208. int stride;
  209. output = c->cur;
  210. prev = c->prev;
  211. stride = c->width * 3;
  212. mvec = (int8_t*)src;
  213. src += ((c->bx * c->by * 2 + 3) & ~3);
  214. block = 0;
  215. for(y = 0; y < c->height; y += c->bh) {
  216. bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
  217. for(x = 0; x < c->width; x += c->bw) {
  218. uint8_t *out, *tprev;
  219. d = mvec[block] & 1;
  220. dx = mvec[block] >> 1;
  221. dy = mvec[block + 1] >> 1;
  222. block += 2;
  223. bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
  224. /* copy block - motion vectors out of bounds are used to zero blocks */
  225. out = output + x * 3;
  226. tprev = prev + (x + dx) * 3 + dy * stride;
  227. mx = x + dx;
  228. my = y + dy;
  229. for(j = 0; j < bh2; j++){
  230. if((my + j < 0) || (my + j >= c->height)) {
  231. memset(out, 0, bw2 * 3);
  232. } else {
  233. for(i = 0; i < bw2; i++){
  234. if((mx + i < 0) || (mx + i >= c->width)) {
  235. out[i * 3 + 0] = 0;
  236. out[i * 3 + 1] = 0;
  237. out[i * 3 + 2] = 0;
  238. } else {
  239. out[i * 3 + 0] = tprev[i * 3 + 0];
  240. out[i * 3 + 1] = tprev[i * 3 + 1];
  241. out[i * 3 + 2] = tprev[i * 3 + 2];
  242. }
  243. }
  244. }
  245. out += stride;
  246. tprev += stride;
  247. }
  248. if(d) { /* apply XOR'ed difference */
  249. out = output + x * 3;
  250. for(j = 0; j < bh2; j++){
  251. for(i = 0; i < bw2; i++) {
  252. out[i * 3 + 0] ^= *src++;
  253. out[i * 3 + 1] ^= *src++;
  254. out[i * 3 + 2] ^= *src++;
  255. }
  256. out += stride;
  257. }
  258. }
  259. }
  260. output += stride * c->bh;
  261. prev += stride * c->bh;
  262. }
  263. if(src - c->decomp_buf != c->decomp_len)
  264. av_log(c->avctx, AV_LOG_ERROR, "Used %i of %i bytes\n", src-c->decomp_buf, c->decomp_len);
  265. return 0;
  266. }
  267. #endif //ZMBV_ENABLE_24BPP
  268. /**
  269. * Decode XOR'ed frame - 32bpp version
  270. */
  271. static int zmbv_decode_xor_32(ZmbvContext *c)
  272. {
  273. uint8_t *src = c->decomp_buf;
  274. uint32_t *output, *prev;
  275. int8_t *mvec;
  276. int x, y;
  277. int d, dx, dy, bw2, bh2;
  278. int block;
  279. int i, j;
  280. int mx, my;
  281. output = (uint32_t*)c->cur;
  282. prev = (uint32_t*)c->prev;
  283. mvec = (int8_t*)src;
  284. src += ((c->bx * c->by * 2 + 3) & ~3);
  285. block = 0;
  286. for(y = 0; y < c->height; y += c->bh) {
  287. bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
  288. for(x = 0; x < c->width; x += c->bw) {
  289. uint32_t *out, *tprev;
  290. d = mvec[block] & 1;
  291. dx = mvec[block] >> 1;
  292. dy = mvec[block + 1] >> 1;
  293. block += 2;
  294. bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
  295. /* copy block - motion vectors out of bounds are used to zero blocks */
  296. out = output + x;
  297. tprev = prev + x + dx + dy * c->width;
  298. mx = x + dx;
  299. my = y + dy;
  300. for(j = 0; j < bh2; j++){
  301. if((my + j < 0) || (my + j >= c->height)) {
  302. memset(out, 0, bw2 * 4);
  303. } else {
  304. for(i = 0; i < bw2; i++){
  305. if((mx + i < 0) || (mx + i >= c->width))
  306. out[i] = 0;
  307. else
  308. out[i] = tprev[i];
  309. }
  310. }
  311. out += c->width;
  312. tprev += c->width;
  313. }
  314. if(d) { /* apply XOR'ed difference */
  315. out = output + x;
  316. for(j = 0; j < bh2; j++){
  317. for(i = 0; i < bw2; i++) {
  318. out[i] ^= *((uint32_t*)src);
  319. src += 4;
  320. }
  321. out += c->width;
  322. }
  323. }
  324. }
  325. output += c->width * c->bh;
  326. prev += c->width * c->bh;
  327. }
  328. if(src - c->decomp_buf != c->decomp_len)
  329. av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
  330. return 0;
  331. }
  332. /**
  333. * Decode intraframe
  334. */
  335. static int zmbv_decode_intra(ZmbvContext *c)
  336. {
  337. uint8_t *src = c->decomp_buf;
  338. /* make the palette available on the way out */
  339. if (c->fmt == ZMBV_FMT_8BPP) {
  340. memcpy(c->pal, src, 768);
  341. src += 768;
  342. }
  343. memcpy(c->cur, src, c->width * c->height * (c->bpp / 8));
  344. return 0;
  345. }
  346. static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
  347. {
  348. ZmbvContext * const c = avctx->priv_data;
  349. uint8_t *outptr;
  350. int zret = Z_OK; // Zlib return code
  351. int len = buf_size;
  352. int hi_ver, lo_ver;
  353. if(c->pic.data[0])
  354. avctx->release_buffer(avctx, &c->pic);
  355. c->pic.reference = 1;
  356. c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
  357. if(avctx->get_buffer(avctx, &c->pic) < 0){
  358. av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
  359. return -1;
  360. }
  361. outptr = c->pic.data[0]; // Output image pointer
  362. /* parse header */
  363. c->flags = buf[0];
  364. buf++; len--;
  365. if(c->flags & ZMBV_KEYFRAME) {
  366. hi_ver = buf[0];
  367. lo_ver = buf[1];
  368. c->comp = buf[2];
  369. c->fmt = buf[3];
  370. c->bw = buf[4];
  371. c->bh = buf[5];
  372. buf += 6;
  373. len -= 6;
  374. av_log(avctx, AV_LOG_DEBUG, "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
  375. if(hi_ver != 0 || lo_ver != 1) {
  376. av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n", hi_ver, lo_ver);
  377. return -1;
  378. }
  379. if(c->bw == 0 || c->bh == 0) {
  380. av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n", c->bw, c->bh);
  381. }
  382. if(c->comp != 0 && c->comp != 1) {
  383. av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n", c->comp);
  384. return -1;
  385. }
  386. switch(c->fmt) {
  387. case ZMBV_FMT_8BPP:
  388. c->bpp = 8;
  389. c->decode_intra = zmbv_decode_intra;
  390. c->decode_xor = zmbv_decode_xor_8;
  391. break;
  392. case ZMBV_FMT_15BPP:
  393. case ZMBV_FMT_16BPP:
  394. c->bpp = 16;
  395. c->decode_intra = zmbv_decode_intra;
  396. c->decode_xor = zmbv_decode_xor_16;
  397. break;
  398. #ifdef ZMBV_ENABLE_24BPP
  399. case ZMBV_FMT_24BPP:
  400. c->bpp = 24;
  401. c->decode_intra = zmbv_decode_intra;
  402. c->decode_xor = zmbv_decode_xor_24;
  403. break;
  404. #endif //ZMBV_ENABLE_24BPP
  405. case ZMBV_FMT_32BPP:
  406. c->bpp = 32;
  407. c->decode_intra = zmbv_decode_intra;
  408. c->decode_xor = zmbv_decode_xor_32;
  409. break;
  410. default:
  411. c->decode_intra = NULL;
  412. c->decode_xor = NULL;
  413. av_log(avctx, AV_LOG_ERROR, "Unsupported (for now) format %i\n", c->fmt);
  414. return -1;
  415. }
  416. zret = inflateReset(&c->zstream);
  417. if (zret != Z_OK) {
  418. av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
  419. return -1;
  420. }
  421. c->cur = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
  422. c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
  423. c->bx = (c->width + c->bw - 1) / c->bw;
  424. c->by = (c->height+ c->bh - 1) / c->bh;
  425. }
  426. if(c->decode_intra == NULL) {
  427. av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
  428. return -1;
  429. }
  430. if(c->comp == 0) { //Uncompressed data
  431. memcpy(c->decomp_buf, buf, len);
  432. c->decomp_size = 1;
  433. } else { // ZLIB-compressed data
  434. c->zstream.total_in = c->zstream.total_out = 0;
  435. c->zstream.next_in = buf;
  436. c->zstream.avail_in = len;
  437. c->zstream.next_out = c->decomp_buf;
  438. c->zstream.avail_out = c->decomp_size;
  439. inflate(&c->zstream, Z_FINISH);
  440. c->decomp_len = c->zstream.total_out;
  441. }
  442. if(c->flags & ZMBV_KEYFRAME) {
  443. c->pic.key_frame = 1;
  444. c->pic.pict_type = FF_I_TYPE;
  445. c->decode_intra(c);
  446. } else {
  447. c->pic.key_frame = 0;
  448. c->pic.pict_type = FF_P_TYPE;
  449. if(c->decomp_len)
  450. c->decode_xor(c);
  451. }
  452. /* update frames */
  453. {
  454. uint8_t *out, *src;
  455. int i, j;
  456. out = c->pic.data[0];
  457. src = c->cur;
  458. switch(c->fmt) {
  459. case ZMBV_FMT_8BPP:
  460. for(j = 0; j < c->height; j++) {
  461. for(i = 0; i < c->width; i++) {
  462. out[i * 3 + 0] = c->pal[(*src) * 3 + 0];
  463. out[i * 3 + 1] = c->pal[(*src) * 3 + 1];
  464. out[i * 3 + 2] = c->pal[(*src) * 3 + 2];
  465. src++;
  466. }
  467. out += c->pic.linesize[0];
  468. }
  469. break;
  470. case ZMBV_FMT_15BPP:
  471. for(j = 0; j < c->height; j++) {
  472. for(i = 0; i < c->width; i++) {
  473. uint16_t tmp = AV_RL16(src);
  474. src += 2;
  475. out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
  476. out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
  477. out[i * 3 + 2] = (tmp & 0x001F) << 3;
  478. }
  479. out += c->pic.linesize[0];
  480. }
  481. break;
  482. case ZMBV_FMT_16BPP:
  483. for(j = 0; j < c->height; j++) {
  484. for(i = 0; i < c->width; i++) {
  485. uint16_t tmp = AV_RL16(src);
  486. src += 2;
  487. out[i * 3 + 0] = (tmp & 0xF800) >> 8;
  488. out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
  489. out[i * 3 + 2] = (tmp & 0x001F) << 3;
  490. }
  491. out += c->pic.linesize[0];
  492. }
  493. break;
  494. #ifdef ZMBV_ENABLE_24BPP
  495. case ZMBV_FMT_24BPP:
  496. for(j = 0; j < c->height; j++) {
  497. memcpy(out, src, c->width * 3);
  498. src += c->width * 3;
  499. out += c->pic.linesize[0];
  500. }
  501. break;
  502. #endif //ZMBV_ENABLE_24BPP
  503. case ZMBV_FMT_32BPP:
  504. for(j = 0; j < c->height; j++) {
  505. for(i = 0; i < c->width; i++) {
  506. uint32_t tmp = AV_RL32(src);
  507. src += 4;
  508. AV_WB24(out+(i*3), tmp);
  509. }
  510. out += c->pic.linesize[0];
  511. }
  512. break;
  513. default:
  514. av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
  515. }
  516. memcpy(c->prev, c->cur, c->width * c->height * (c->bpp / 8));
  517. }
  518. *data_size = sizeof(AVFrame);
  519. *(AVFrame*)data = c->pic;
  520. /* always report that the buffer was completely consumed */
  521. return buf_size;
  522. }
  523. /*
  524. *
  525. * Init zmbv decoder
  526. *
  527. */
  528. static av_cold int decode_init(AVCodecContext *avctx)
  529. {
  530. ZmbvContext * const c = avctx->priv_data;
  531. int zret; // Zlib return code
  532. c->avctx = avctx;
  533. c->pic.data[0] = NULL;
  534. c->width = avctx->width;
  535. c->height = avctx->height;
  536. if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
  537. return 1;
  538. }
  539. c->bpp = avctx->bits_per_coded_sample;
  540. // Needed if zlib unused or init aborted before inflateInit
  541. memset(&(c->zstream), 0, sizeof(z_stream));
  542. avctx->pix_fmt = PIX_FMT_RGB24;
  543. c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64);
  544. /* Allocate decompression buffer */
  545. if (c->decomp_size) {
  546. if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) {
  547. av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
  548. return 1;
  549. }
  550. }
  551. c->zstream.zalloc = Z_NULL;
  552. c->zstream.zfree = Z_NULL;
  553. c->zstream.opaque = Z_NULL;
  554. zret = inflateInit(&(c->zstream));
  555. if (zret != Z_OK) {
  556. av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
  557. return 1;
  558. }
  559. return 0;
  560. }
  561. /*
  562. *
  563. * Uninit zmbv decoder
  564. *
  565. */
  566. static av_cold int decode_end(AVCodecContext *avctx)
  567. {
  568. ZmbvContext * const c = avctx->priv_data;
  569. av_freep(&c->decomp_buf);
  570. if (c->pic.data[0])
  571. avctx->release_buffer(avctx, &c->pic);
  572. inflateEnd(&(c->zstream));
  573. av_freep(&c->cur);
  574. av_freep(&c->prev);
  575. return 0;
  576. }
  577. AVCodec zmbv_decoder = {
  578. "zmbv",
  579. CODEC_TYPE_VIDEO,
  580. CODEC_ID_ZMBV,
  581. sizeof(ZmbvContext),
  582. decode_init,
  583. NULL,
  584. decode_end,
  585. decode_frame,
  586. .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
  587. };