History

avcodec/vmixdec: add support for custom first byte

Paul B Mahol committed 3 years ago

Commit 00a837c1 parent 038b9921 file · +27 −9Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vmixdec.c+27−9
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <stdlib.h>
2424 #include <string.h>
2525
26−#include "libavutil/avassert.h"
2726 #include "libavutil/intreadwrite.h"
2827 #include "libavutil/mem_internal.h"
2928
@@ -45,6 +44,7 @@ typedef struct SliceContext { · 15 unmodified lines
4544
4645 typedef struct VMIXContext {
4746 int nb_slices;
47+ int lshift;
4848
4949 int16_t factors[64];
5050 uint8_t scan[64];
@@ -55,9 +55,22 @@ typedef struct VMIXContext { · 4 unmodified lines
5555 IDCTDSPContext idsp;
5656 } VMIXContext;
5757
58−static const uint8_t quality[25] = {
59− 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16,
60− 18, 20, 22, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64,
58+static const uint8_t quality[256] = {
59+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
60+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
61+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
62+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
63+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 64, 56, 52, 48, 44,
64+ 12, 36, 32, 28, 24, 22, 20, 18, 16, 14, 12, 10, 8, 7, 6, 5,
65+ 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
66+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
67+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
68+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
69+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
70+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
71+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
72+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
73+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
6174 };
6275
6376 static const uint8_t quant[64] = {
@@ -108,6 +121,7 @@ static int decode_dcac(AVCodecContext *avctx, · 44 unmodified lines
108121 const uint8_t *scan = s->scan;
109122 const int add = plane ? 0 : 1024;
110123 int i, dc_v = 0, ac_v = 0, dc = 0;
124+ const int lshift = s->lshift;
111125
112126 for (int y = 0; y < 2; y++) {
113127 for (int x = 0; x < width; x += 8) {
@@ -139,7 +153,7 @@ static int decode_dcac(AVCodecContext *avctx, · 25 unmodified lines
139153 ac_run = get_ue_golomb_long(ac_gb);
140154 }
141155
142− block[0] = dc + add;
156+ block[0] = (dc << lshift) + add;
143157 s->idsp.idct_put(dst + x, linesize, block);
144158 }
145159
@@ -213,18 +227,22 @@ static int decode_frame(AVCodecContext *avctx, · 67 unmodified lines
213227 AVPacket *avpkt)
214228 {
215229 VMIXContext *s = avctx->priv_data;
216− unsigned offset = 3, q;
230+ unsigned offset, q;
217231 int ret;
218232
219233 if (avpkt->size <= 7)
220234 return AVERROR_INVALIDDATA;
221235
222− if (avpkt->data[0] != 0x01)
236+ s->lshift = 0;
237+ offset = 2 + avpkt->data[0];
238+ if (offset == 5)
239+ s->lshift = avpkt->data[1];
240+ else if (offset != 3)
223241 return AVERROR_INVALIDDATA;
224242
225− q = av_clip(99 - av_clip(avpkt->data[1], 0, 99), 0, FF_ARRAY_ELEMS(quality) - 1);
243+ q = quality[avpkt->data[offset - 2]];
226244 for (int n = 0; n < 64; n++)
227− s->factors[n] = quant[n] * quality[q];
245+ s->factors[n] = quant[n] * q;
228246
229247 s->nb_slices = (avctx->height + 15) / 16;
230248 av_fast_mallocz(&s->slices, &s->slices_size, s->nb_slices * sizeof(*s->slices));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t