FFmpeg: libavcodec/mss1.c Source File
Go to the documentation of this file. 1 /*
2 * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
3 * Copyright (c) 2012 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 /**
23 * @file
24 * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
25 */
26
31
37
39 {
40 for (;;) {
41 if (
c->high >= 0x8000) {
42 if (
c->low < 0x8000) {
43 if (
c->low >= 0x4000 &&
c->high < 0xC000) {
47 } else {
48 return;
49 }
50 } else {
54 }
55 }
63 }
64 }
65
67
69 {
70 int range =
c->high -
c->low + 1;
73
76
78
80 }
81
83 {
84 int range =
c->high -
c->low + 1;
85 int val = ((
c->value -
c->low + 1) * mod_val - 1) /
range;
87
89 c->low +=
prob / mod_val;
90
92
94 }
95
97 {
98 int range =
c->high -
c->low + 1;
99 int val = ((
c->value -
c->low + 1) * probs[0] - 1) /
range;
100 int sym = 1;
101
102 while (probs[sym] >
val)
103 sym++;
104
105 c->high =
range * probs[sym - 1] / probs[0] +
c->low - 1;
106 c->low +=
range * probs[sym] / probs[0];
107
108 return sym;
109 }
110
112
114 {
120 c->get_model_sym = arith_get_model_sym;
122 }
123
125 {
126 int i, ncol,
r,
g,
b;
127 uint32_t *pal =
ctx->pal + 256 -
ctx->free_colours;
128
129 if (!
ctx->free_colours)
130 return 0;
131
133 for (
i = 0;
i < ncol;
i++) {
137 *pal++ = (0xFF
U << 24) | (
r << 16) | (
g << 8) |
b;
138 }
139
140 return !!ncol;
141 }
142
145 {
150 int pal_changed = 0;
152
155
157
160
161 c->pal_pic =
ctx->pic->data[0] +
ctx->pic->linesize[0] * (avctx->
height - 1);
162 c->pal_stride = -
ctx->pic->linesize[0];
163 c->keyframe = !arith_get_bit(&acoder);
170 } else {
175 }
181 #if FF_API_PALETTE_HAS_CHANGED
183 ctx->pic->palette_has_changed = pal_changed;
185 #endif
186
189
190 *got_frame = 1;
191
192 /* always report that the buffer was completely consumed */
194 }
195
197 {
200
201 c->ctx.avctx = avctx;
202
206
210
212
214 }
215
217 {
219
222
223 return 0;
224 }
225
237 };
#define FF_ENABLE_DEPRECATION_WARNINGS
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int get_bits_left(GetBitContext *gb)
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int arith_get_number(ArithCoder *c, int mod_val)
#define ARITH_GET_MODEL_SYM(prefix)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static int arith_get_prob(ArithCoder *c, int16_t *probs)
static av_cold int mss1_decode_init(AVCodecContext *avctx)
static int mss1_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
static double val(void *priv, double ch)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#define FF_CODEC_DECODE_CB(func)
int flags
Flags modifying the (de)muxer behaviour.
#define CODEC_LONG_NAME(str)
const FFCodec ff_mss1_decoder
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static av_cold int mss1_decode_end(AVCodecContext *avctx)
#define ARITH_GET_BIT(prefix)
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static int arith_get_bits(ArithCoder *c, int bits)
#define i(width, name, range_min, range_max)
static void arith_init(ArithCoder *c, GetBitContext *gb)
av_cold int ff_mss12_decode_end(MSS12Context *c)
const char * name
Name of the codec implementation.
static void arith_normalise(ArithCoder *c)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
#define prob(name, subs,...)
main external API structure.
static int decode_pal(MSS12Context *ctx, ArithCoder *acoder)
#define FF_DISABLE_DEPRECATION_WARNINGS
int ff_mss12_decode_rect(SliceContext *sc, ArithCoder *acoder, int x, int y, int width, int height)
@ AV_PICTURE_TYPE_P
Predicted.
This structure stores compressed data.
void ff_mss12_slicecontext_reset(SliceContext *sc)
int width
picture width / height.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
av_cold int ff_mss12_decode_init(MSS12Context *c, int version, SliceContext *sc1, SliceContext *sc2)
Generated on Thu Sep 26 2024 23:15:14 for FFmpeg by
doxygen
1.8.17