History

avcodec/vmixdec: add support for custom first byte

Paul B Mahol committed 3 years ago

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

Unified · Split

libavcodec/vmixdec.c+27−9
@@ -23,7 +23,6 @@ · 22 unmodified lines
23#include <stdlib.h>23#include <stdlib.h>
24#include <string.h>24#include <string.h>
25 25
26#include "libavutil/avassert.h"
27#include "libavutil/intreadwrite.h"26#include "libavutil/intreadwrite.h"
28#include "libavutil/mem_internal.h"27#include "libavutil/mem_internal.h"
29 28
@@ -45,6 +44,7 @@ typedef struct SliceContext { · 15 unmodified lines
45 44
46typedef struct VMIXContext {45typedef struct VMIXContext {
47 int nb_slices;46 int nb_slices;
47 int lshift;
48 48
49 int16_t factors[64];49 int16_t factors[64];
50 uint8_t scan[64];50 uint8_t scan[64];
@@ -55,9 +55,22 @@ typedef struct VMIXContext { · 4 unmodified lines
55 IDCTDSPContext idsp;55 IDCTDSPContext idsp;
56} VMIXContext;56} VMIXContext;
57 57
58static const uint8_t quality[25] = {58static const uint8_t quality[256] = {
59 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16,59 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
60 18, 20, 22, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64,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,
61};74};
62 75
63static const uint8_t quant[64] = {76static const uint8_t quant[64] = {
@@ -108,6 +121,7 @@ static int decode_dcac(AVCodecContext *avctx, · 44 unmodified lines
108 const uint8_t *scan = s->scan;121 const uint8_t *scan = s->scan;
109 const int add = plane ? 0 : 1024;122 const int add = plane ? 0 : 1024;
110 int i, dc_v = 0, ac_v = 0, dc = 0;123 int i, dc_v = 0, ac_v = 0, dc = 0;
124 const int lshift = s->lshift;
111 125
112 for (int y = 0; y < 2; y++) {126 for (int y = 0; y < 2; y++) {
113 for (int x = 0; x < width; x += 8) {127 for (int x = 0; x < width; x += 8) {
@@ -139,7 +153,7 @@ static int decode_dcac(AVCodecContext *avctx, · 25 unmodified lines
139 ac_run = get_ue_golomb_long(ac_gb);153 ac_run = get_ue_golomb_long(ac_gb);
140 }154 }
141 155
142 block[0] = dc + add;156 block[0] = (dc << lshift) + add;
143 s->idsp.idct_put(dst + x, linesize, block);157 s->idsp.idct_put(dst + x, linesize, block);
144 }158 }
145 159
@@ -213,18 +227,22 @@ static int decode_frame(AVCodecContext *avctx, · 67 unmodified lines
213 AVPacket *avpkt)227 AVPacket *avpkt)
214{228{
215 VMIXContext *s = avctx->priv_data;229 VMIXContext *s = avctx->priv_data;
216 unsigned offset = 3, q;230 unsigned offset, q;
217 int ret;231 int ret;
218 232
219 if (avpkt->size <= 7)233 if (avpkt->size <= 7)
220 return AVERROR_INVALIDDATA;234 return AVERROR_INVALIDDATA;
221 235
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)
223 return AVERROR_INVALIDDATA;241 return AVERROR_INVALIDDATA;
224 242
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]];
226 for (int n = 0; n < 64; n++)244 for (int n = 0; n < 64; n++)
227 s->factors[n] = quant[n] * quality[q];245 s->factors[n] = quant[n] * q;
228 246
229 s->nb_slices = (avctx->height + 15) / 16;247 s->nb_slices = (avctx->height + 15) / 16;
230 av_fast_mallocz(&s->slices, &s->slices_size, s->nb_slices * sizeof(*s->slices));248 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