summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/bink.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffmpeg/libavcodec/bink.c')
-rw-r--r--ffmpeg/libavcodec/bink.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/ffmpeg/libavcodec/bink.c b/ffmpeg/libavcodec/bink.c
index 9bab4b9..f23542f 100644
--- a/ffmpeg/libavcodec/bink.c
+++ b/ffmpeg/libavcodec/bink.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "avcodec.h"
@@ -119,6 +120,7 @@ typedef struct BinkContext {
int version; ///< internal Bink file version
int has_alpha;
int swap_planes;
+ unsigned frame_num;
Bundle bundle[BINKB_NB_SRC]; ///< bundles for decoding all data types
Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type
@@ -142,7 +144,7 @@ enum BlockTypes {
};
/**
- * Initialize length length in all bundles.
+ * Initialize length in all bundles.
*
* @param c decoder context
* @param width plane width
@@ -183,7 +185,7 @@ static av_cold int init_bundles(BinkContext *c)
blocks = bw * bh;
for (i = 0; i < BINKB_NB_SRC; i++) {
- c->bundle[i].data = av_malloc(blocks * 64);
+ c->bundle[i].data = av_mallocz(blocks * 64);
if (!c->bundle[i].data)
return AVERROR(ENOMEM);
c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
@@ -528,14 +530,14 @@ static inline int get_value(BinkContext *c, int bundle)
return ret;
}
-static void binkb_init_bundle(BinkContext *c, int bundle_num)
+static av_cold void binkb_init_bundle(BinkContext *c, int bundle_num)
{
c->bundle[bundle_num].cur_dec =
c->bundle[bundle_num].cur_ptr = c->bundle[bundle_num].data;
c->bundle[bundle_num].len = 13;
}
-static void binkb_init_bundles(BinkContext *c)
+static av_cold void binkb_init_bundles(BinkContext *c)
{
int i;
for (i = 0; i < BINKB_NB_SRC; i++)
@@ -1205,6 +1207,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
if (c->version >= 'i')
skip_bits_long(&gb, 32);
+ c->frame_num++;
+
for (plane = 0; plane < 3; plane++) {
plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);
@@ -1213,7 +1217,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
return ret;
} else {
if ((ret = binkb_decode_plane(c, frame, &gb, plane_idx,
- !avctx->frame_number, !!plane)) < 0)
+ c->frame_num == 1, !!plane)) < 0)
return ret;
}
if (get_bits_count(&gb) >= bits_count)
@@ -1331,14 +1335,22 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
+static void flush(AVCodecContext *avctx)
+{
+ BinkContext * const c = avctx->priv_data;
+
+ c->frame_num = 0;
+}
+
AVCodec ff_bink_decoder = {
.name = "binkvideo",
+ .long_name = NULL_IF_CONFIG_SMALL("Bink video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_BINKVIDEO,
.priv_data_size = sizeof(BinkContext),
.init = decode_init,
.close = decode_end,
.decode = decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("Bink video"),
+ .flush = flush,
.capabilities = CODEC_CAP_DR1,
};