~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/zmbv.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
    output = c->cur;
89
89
    prev = c->prev;
90
90
 
91
 
    if(c->flags & ZMBV_DELTAPAL){
92
 
        for(i = 0; i < 768; i++)
 
91
    if (c->flags & ZMBV_DELTAPAL) {
 
92
        for (i = 0; i < 768; i++)
93
93
            c->pal[i] ^= *src++;
94
94
    }
95
95
 
97
97
    src += ((c->bx * c->by * 2 + 3) & ~3);
98
98
 
99
99
    block = 0;
100
 
    for(y = 0; y < c->height; y += c->bh) {
 
100
    for (y = 0; y < c->height; y += c->bh) {
101
101
        bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
102
 
        for(x = 0; x < c->width; x += c->bw) {
 
102
        for (x = 0; x < c->width; x += c->bw) {
103
103
            uint8_t *out, *tprev;
104
104
 
105
105
            d = mvec[block] & 1;
114
114
            tprev = prev + x + dx + dy * c->width;
115
115
            mx = x + dx;
116
116
            my = y + dy;
117
 
            for(j = 0; j < bh2; j++){
118
 
                if((my + j < 0) || (my + j >= c->height)) {
 
117
            for (j = 0; j < bh2; j++) {
 
118
                if (my + j < 0 || my + j >= c->height) {
119
119
                    memset(out, 0, bw2);
120
120
                } else {
121
 
                    for(i = 0; i < bw2; i++){
122
 
                        if((mx + i < 0) || (mx + i >= c->width))
 
121
                    for (i = 0; i < bw2; i++) {
 
122
                        if (mx + i < 0 || mx + i >= c->width)
123
123
                            out[i] = 0;
124
124
                        else
125
125
                            out[i] = tprev[i];
129
129
                tprev += c->width;
130
130
            }
131
131
 
132
 
            if(d) { /* apply XOR'ed difference */
 
132
            if (d) { /* apply XOR'ed difference */
133
133
                out = output + x;
134
 
                for(j = 0; j < bh2; j++){
135
 
                    for(i = 0; i < bw2; i++)
 
134
                for (j = 0; j < bh2; j++) {
 
135
                    for (i = 0; i < bw2; i++)
136
136
                        out[i] ^= *src++;
137
137
                    out += c->width;
138
138
                }
141
141
        output += c->width * c->bh;
142
142
        prev += c->width * c->bh;
143
143
    }
144
 
    if(src - c->decomp_buf != c->decomp_len)
145
 
        av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
 
144
    if (src - c->decomp_buf != c->decomp_len)
 
145
        av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
 
146
               src-c->decomp_buf, c->decomp_len);
146
147
    return 0;
147
148
}
148
149
 
168
169
    src += ((c->bx * c->by * 2 + 3) & ~3);
169
170
 
170
171
    block = 0;
171
 
    for(y = 0; y < c->height; y += c->bh) {
 
172
    for (y = 0; y < c->height; y += c->bh) {
172
173
        bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
173
 
        for(x = 0; x < c->width; x += c->bw) {
 
174
        for (x = 0; x < c->width; x += c->bw) {
174
175
            uint16_t *out, *tprev;
175
176
 
176
177
            d = mvec[block] & 1;
185
186
            tprev = prev + x + dx + dy * c->width;
186
187
            mx = x + dx;
187
188
            my = y + dy;
188
 
            for(j = 0; j < bh2; j++){
189
 
                if((my + j < 0) || (my + j >= c->height)) {
 
189
            for (j = 0; j < bh2; j++) {
 
190
                if (my + j < 0 || my + j >= c->height) {
190
191
                    memset(out, 0, bw2 * 2);
191
192
                } else {
192
 
                    for(i = 0; i < bw2; i++){
193
 
                        if((mx + i < 0) || (mx + i >= c->width))
 
193
                    for (i = 0; i < bw2; i++) {
 
194
                        if (mx + i < 0 || mx + i >= c->width)
194
195
                            out[i] = 0;
195
196
                        else
196
197
                            out[i] = tprev[i];
200
201
                tprev += c->width;
201
202
            }
202
203
 
203
 
            if(d) { /* apply XOR'ed difference */
 
204
            if (d) { /* apply XOR'ed difference */
204
205
                out = output + x;
205
 
                for(j = 0; j < bh2; j++){
206
 
                    for(i = 0; i < bw2; i++) {
 
206
                for (j = 0; j < bh2; j++){
 
207
                    for (i = 0; i < bw2; i++) {
207
208
                        out[i] ^= *((uint16_t*)src);
208
209
                        src += 2;
209
210
                    }
214
215
        output += c->width * c->bh;
215
216
        prev += c->width * c->bh;
216
217
    }
217
 
    if(src - c->decomp_buf != c->decomp_len)
218
 
        av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
 
218
    if (src - c->decomp_buf != c->decomp_len)
 
219
        av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
 
220
               src-c->decomp_buf, c->decomp_len);
219
221
    return 0;
220
222
}
221
223
 
244
246
    src += ((c->bx * c->by * 2 + 3) & ~3);
245
247
 
246
248
    block = 0;
247
 
    for(y = 0; y < c->height; y += c->bh) {
 
249
    for (y = 0; y < c->height; y += c->bh) {
248
250
        bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
249
 
        for(x = 0; x < c->width; x += c->bw) {
 
251
        for (x = 0; x < c->width; x += c->bw) {
250
252
            uint8_t *out, *tprev;
251
253
 
252
254
            d = mvec[block] & 1;
261
263
            tprev = prev + (x + dx) * 3 + dy * stride;
262
264
            mx = x + dx;
263
265
            my = y + dy;
264
 
            for(j = 0; j < bh2; j++){
265
 
                if((my + j < 0) || (my + j >= c->height)) {
 
266
            for (j = 0; j < bh2; j++) {
 
267
                if (my + j < 0 || my + j >= c->height) {
266
268
                    memset(out, 0, bw2 * 3);
267
269
                } else {
268
 
                    for(i = 0; i < bw2; i++){
269
 
                        if((mx + i < 0) || (mx + i >= c->width)) {
 
270
                    for (i = 0; i < bw2; i++){
 
271
                        if (mx + i < 0 || mx + i >= c->width) {
270
272
                            out[i * 3 + 0] = 0;
271
273
                            out[i * 3 + 1] = 0;
272
274
                            out[i * 3 + 2] = 0;
281
283
                tprev += stride;
282
284
            }
283
285
 
284
 
            if(d) { /* apply XOR'ed difference */
 
286
            if (d) { /* apply XOR'ed difference */
285
287
                out = output + x * 3;
286
 
                for(j = 0; j < bh2; j++){
287
 
                    for(i = 0; i < bw2; i++) {
 
288
                for (j = 0; j < bh2; j++) {
 
289
                    for (i = 0; i < bw2; i++) {
288
290
                        out[i * 3 + 0] ^= *src++;
289
291
                        out[i * 3 + 1] ^= *src++;
290
292
                        out[i * 3 + 2] ^= *src++;
296
298
        output += stride * c->bh;
297
299
        prev += stride * c->bh;
298
300
    }
299
 
    if(src - c->decomp_buf != c->decomp_len)
300
 
        av_log(c->avctx, AV_LOG_ERROR, "Used %i of %i bytes\n", src-c->decomp_buf, c->decomp_len);
 
301
    if (src - c->decomp_buf != c->decomp_len)
 
302
        av_log(c->avctx, AV_LOG_ERROR, "Used %i of %i bytes\n",
 
303
               src-c->decomp_buf, c->decomp_len);
301
304
    return 0;
302
305
}
303
306
#endif //ZMBV_ENABLE_24BPP
324
327
    src += ((c->bx * c->by * 2 + 3) & ~3);
325
328
 
326
329
    block = 0;
327
 
    for(y = 0; y < c->height; y += c->bh) {
 
330
    for (y = 0; y < c->height; y += c->bh) {
328
331
        bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
329
 
        for(x = 0; x < c->width; x += c->bw) {
 
332
        for (x = 0; x < c->width; x += c->bw) {
330
333
            uint32_t *out, *tprev;
331
334
 
332
335
            d = mvec[block] & 1;
341
344
            tprev = prev + x + dx + dy * c->width;
342
345
            mx = x + dx;
343
346
            my = y + dy;
344
 
            for(j = 0; j < bh2; j++){
345
 
                if((my + j < 0) || (my + j >= c->height)) {
 
347
            for (j = 0; j < bh2; j++) {
 
348
                if (my + j < 0 || my + j >= c->height) {
346
349
                    memset(out, 0, bw2 * 4);
347
350
                } else {
348
 
                    for(i = 0; i < bw2; i++){
349
 
                        if((mx + i < 0) || (mx + i >= c->width))
 
351
                    for (i = 0; i < bw2; i++){
 
352
                        if (mx + i < 0 || mx + i >= c->width)
350
353
                            out[i] = 0;
351
354
                        else
352
355
                            out[i] = tprev[i];
356
359
                tprev += c->width;
357
360
            }
358
361
 
359
 
            if(d) { /* apply XOR'ed difference */
 
362
            if (d) { /* apply XOR'ed difference */
360
363
                out = output + x;
361
 
                for(j = 0; j < bh2; j++){
362
 
                    for(i = 0; i < bw2; i++) {
363
 
                        out[i] ^= *((uint32_t*)src);
 
364
                for (j = 0; j < bh2; j++){
 
365
                    for (i = 0; i < bw2; i++) {
 
366
                        out[i] ^= *((uint32_t *) src);
364
367
                        src += 4;
365
368
                    }
366
369
                    out += c->width;
368
371
            }
369
372
        }
370
373
        output += c->width * c->bh;
371
 
        prev += c->width * c->bh;
 
374
        prev   += c->width * c->bh;
372
375
    }
373
 
    if(src - c->decomp_buf != c->decomp_len)
374
 
        av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
 
376
    if (src - c->decomp_buf != c->decomp_len)
 
377
        av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
 
378
               src-c->decomp_buf, c->decomp_len);
375
379
    return 0;
376
380
}
377
381
 
401
405
    int len = buf_size;
402
406
    int hi_ver, lo_ver;
403
407
 
404
 
    if(c->pic.data[0])
 
408
    if (c->pic.data[0])
405
409
            avctx->release_buffer(avctx, &c->pic);
406
410
 
407
411
    c->pic.reference = 1;
408
412
    c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
409
 
    if(avctx->get_buffer(avctx, &c->pic) < 0){
 
413
    if (avctx->get_buffer(avctx, &c->pic) < 0) {
410
414
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
411
415
        return -1;
412
416
    }
414
418
    /* parse header */
415
419
    c->flags = buf[0];
416
420
    buf++; len--;
417
 
    if(c->flags & ZMBV_KEYFRAME) {
 
421
    if (c->flags & ZMBV_KEYFRAME) {
418
422
        hi_ver = buf[0];
419
423
        lo_ver = buf[1];
420
424
        c->comp = buf[2];
424
428
 
425
429
        buf += 6;
426
430
        len -= 6;
427
 
        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);
428
 
        if(hi_ver != 0 || lo_ver != 1) {
429
 
            av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n", hi_ver, lo_ver);
430
 
            return -1;
431
 
        }
432
 
        if(c->bw == 0 || c->bh == 0) {
433
 
            av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n", c->bw, c->bh);
434
 
            return -1;
435
 
        }
436
 
        if(c->comp != 0 && c->comp != 1) {
437
 
            av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n", c->comp);
 
431
        av_log(avctx, AV_LOG_DEBUG,
 
432
               "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
 
433
               c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
 
434
        if (hi_ver != 0 || lo_ver != 1) {
 
435
            av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n",
 
436
            hi_ver, lo_ver);
 
437
            return -1;
 
438
        }
 
439
        if (c->bw == 0 || c->bh == 0) {
 
440
            av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n",
 
441
                   c->bw, c->bh);
 
442
            return -1;
 
443
        }
 
444
        if (c->comp != 0 && c->comp != 1) {
 
445
            av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n",
 
446
                   c->comp);
438
447
            return -1;
439
448
        }
440
449
 
441
 
        switch(c->fmt) {
 
450
        switch (c->fmt) {
442
451
        case ZMBV_FMT_8BPP:
443
452
            c->bpp = 8;
444
453
            c->decode_intra = zmbv_decode_intra;
465
474
        default:
466
475
            c->decode_intra = NULL;
467
476
            c->decode_xor = NULL;
468
 
            av_log(avctx, AV_LOG_ERROR, "Unsupported (for now) format %i\n", c->fmt);
 
477
            av_log(avctx, AV_LOG_ERROR,
 
478
                   "Unsupported (for now) format %i\n", c->fmt);
469
479
            return -1;
470
480
        }
471
481
 
473
483
        if (zret != Z_OK) {
474
484
            av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
475
485
            return -1;
476
 
        }
477
 
 
478
 
        c->cur = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
479
 
        c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
480
 
        c->bx = (c->width + c->bw - 1) / c->bw;
481
 
        c->by = (c->height+ c->bh - 1) / c->bh;
482
 
    }
483
 
 
484
 
    if(c->decode_intra == NULL) {
485
 
        av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
486
 
        return -1;
487
 
    }
488
 
 
489
 
    if(c->comp == 0) { //Uncompressed data
490
 
        memcpy(c->decomp_buf, buf, len);
491
 
        c->decomp_size = 1;
492
 
    } else { // ZLIB-compressed data
 
486
         }
 
487
 
 
488
         c->cur  = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
 
489
         c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
 
490
         c->bx = (c->width + c->bw - 1) / c->bw;
 
491
         c->by = (c->height+ c->bh - 1) / c->bh;
 
492
     }
 
493
 
 
494
     if (c->decode_intra == NULL) {
 
495
         av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
 
496
         return -1;
 
497
     }
 
498
 
 
499
     if (c->comp == 0) { //Uncompressed data
 
500
         memcpy(c->decomp_buf, buf, len);
 
501
         c->decomp_size = 1;
 
502
     } else { // ZLIB-compressed data
493
503
        c->zstream.total_in = c->zstream.total_out = 0;
494
504
        c->zstream.next_in = buf;
495
505
        c->zstream.avail_in = len;
498
508
        inflate(&c->zstream, Z_FINISH);
499
509
        c->decomp_len = c->zstream.total_out;
500
510
    }
501
 
    if(c->flags & ZMBV_KEYFRAME) {
 
511
    if (c->flags & ZMBV_KEYFRAME) {
502
512
        c->pic.key_frame = 1;
503
513
        c->pic.pict_type = AV_PICTURE_TYPE_I;
504
514
        c->decode_intra(c);
505
515
    } else {
506
516
        c->pic.key_frame = 0;
507
517
        c->pic.pict_type = AV_PICTURE_TYPE_P;
508
 
        if(c->decomp_len)
 
518
        if (c->decomp_len)
509
519
            c->decode_xor(c);
510
520
    }
511
521
 
516
526
 
517
527
        out = c->pic.data[0];
518
528
        src = c->cur;
519
 
        switch(c->fmt) {
 
529
        switch (c->fmt) {
520
530
        case ZMBV_FMT_8BPP:
521
 
            for(j = 0; j < c->height; j++) {
522
 
                for(i = 0; i < c->width; i++) {
 
531
            for (j = 0; j < c->height; j++) {
 
532
                for (i = 0; i < c->width; i++) {
523
533
                    out[i * 3 + 0] = c->pal[(*src) * 3 + 0];
524
534
                    out[i * 3 + 1] = c->pal[(*src) * 3 + 1];
525
535
                    out[i * 3 + 2] = c->pal[(*src) * 3 + 2];
529
539
            }
530
540
            break;
531
541
        case ZMBV_FMT_15BPP:
532
 
            for(j = 0; j < c->height; j++) {
533
 
                for(i = 0; i < c->width; i++) {
 
542
            for (j = 0; j < c->height; j++) {
 
543
                for (i = 0; i < c->width; i++) {
534
544
                    uint16_t tmp = AV_RL16(src);
535
545
                    src += 2;
536
546
                    out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
541
551
            }
542
552
            break;
543
553
        case ZMBV_FMT_16BPP:
544
 
            for(j = 0; j < c->height; j++) {
545
 
                for(i = 0; i < c->width; i++) {
 
554
            for (j = 0; j < c->height; j++) {
 
555
                for (i = 0; i < c->width; i++) {
546
556
                    uint16_t tmp = AV_RL16(src);
547
557
                    src += 2;
548
558
                    out[i * 3 + 0] = (tmp & 0xF800) >> 8;
554
564
            break;
555
565
#ifdef ZMBV_ENABLE_24BPP
556
566
        case ZMBV_FMT_24BPP:
557
 
            for(j = 0; j < c->height; j++) {
 
567
            for (j = 0; j < c->height; j++) {
558
568
                memcpy(out, src, c->width * 3);
559
569
                src += c->width * 3;
560
570
                out += c->pic.linesize[0];
562
572
            break;
563
573
#endif //ZMBV_ENABLE_24BPP
564
574
        case ZMBV_FMT_32BPP:
565
 
            for(j = 0; j < c->height; j++) {
566
 
                for(i = 0; i < c->width; i++) {
 
575
            for (j = 0; j < c->height; j++) {
 
576
                for (i = 0; i < c->width; i++) {
567
577
                    uint32_t tmp = AV_RL32(src);
568
578
                    src += 4;
569
579
                    AV_WB24(out+(i*3), tmp);
574
584
        default:
575
585
            av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
576
586
        }
577
 
        memcpy(c->prev, c->cur, c->width * c->height * (c->bpp / 8));
 
587
        FFSWAP(uint8_t *, c->cur, c->prev);
578
588
    }
579
589
    *data_size = sizeof(AVFrame);
580
590
    *(AVFrame*)data = c->pic;
603
613
    c->bpp = avctx->bits_per_coded_sample;
604
614
 
605
615
    // Needed if zlib unused or init aborted before inflateInit
606
 
    memset(&(c->zstream), 0, sizeof(z_stream));
 
616
    memset(&c->zstream, 0, sizeof(z_stream));
607
617
 
608
618
    avctx->pix_fmt = PIX_FMT_RGB24;
609
619
    c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64);
611
621
    /* Allocate decompression buffer */
612
622
    if (c->decomp_size) {
613
623
        if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) {
614
 
            av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
 
624
            av_log(avctx, AV_LOG_ERROR,
 
625
                   "Can't allocate decompression buffer.\n");
615
626
            return 1;
616
627
        }
617
628
    }
619
630
    c->zstream.zalloc = Z_NULL;
620
631
    c->zstream.zfree = Z_NULL;
621
632
    c->zstream.opaque = Z_NULL;
622
 
    zret = inflateInit(&(c->zstream));
 
633
    zret = inflateInit(&c->zstream);
623
634
    if (zret != Z_OK) {
624
635
        av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
625
636
        return 1;
643
654
 
644
655
    if (c->pic.data[0])
645
656
        avctx->release_buffer(avctx, &c->pic);
646
 
    inflateEnd(&(c->zstream));
 
657
    inflateEnd(&c->zstream);
647
658
    av_freep(&c->cur);
648
659
    av_freep(&c->prev);
649
660
 
651
662
}
652
663
 
653
664
AVCodec ff_zmbv_decoder = {
654
 
    "zmbv",
655
 
    AVMEDIA_TYPE_VIDEO,
656
 
    CODEC_ID_ZMBV,
657
 
    sizeof(ZmbvContext),
658
 
    decode_init,
659
 
    NULL,
660
 
    decode_end,
661
 
    decode_frame,
662
 
    CODEC_CAP_DR1,
 
665
    .name           = "zmbv",
 
666
    .type           = AVMEDIA_TYPE_VIDEO,
 
667
    .id             = CODEC_ID_ZMBV,
 
668
    .priv_data_size = sizeof(ZmbvContext),
 
669
    .init           = decode_init,
 
670
    .close          = decode_end,
 
671
    .decode         = decode_frame,
 
672
    .capabilities   = CODEC_CAP_DR1,
663
673
    .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
664
674
};
665
675