History

avfilter/vf_framepack: add >8 format support

Paul B Mahol committed 5 years ago

Commit cfcc3621 parent 73ff84c1 file · +64 −6Browse files

Unified · Split

libavfilter/vf_framepack.c+64−6
@@ -44,6 +44,7 @@ · 43 unmodified lines
4444 typedef struct FramepackContext {
4545 const AVClass *class;
4646
47+ int depth;
4748 const AVPixFmtDescriptor *pix_desc; ///< agreed pixel format
4849
4950 enum AVStereo3DType format; ///< frame pack type output
@@ -52,9 +53,29 @@ typedef struct FramepackContext { · 2 unmodified lines
5253 } FramepackContext;
5354
5455 static const enum AVPixelFormat formats_supported[] = {
55− AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
56− AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVJ420P,
57− AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,
56+ AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9,
57+ AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
58+ AV_PIX_FMT_GRAY16,
59+ AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
60+ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
61+ AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
62+ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
63+ AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
64+ AV_PIX_FMT_YUVJ411P,
65+ AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
66+ AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
67+ AV_PIX_FMT_YUV440P10,
68+ AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
69+ AV_PIX_FMT_YUV440P12,
70+ AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
71+ AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
72+ AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
73+ AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
74+ AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
75+ AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
76+ AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
77+ AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
78+ AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
5879 AV_PIX_FMT_NONE
5980 };
6081
@@ -113,6 +134,7 @@ static int config_output(AVFilterLink *outlink) · 52 unmodified lines
113134 s->pix_desc = av_pix_fmt_desc_get(outlink->format);
114135 if (!s->pix_desc)
115136 return AVERROR_BUG;
137+ s->depth = s->pix_desc->comp[0].depth;
116138
117139 // modify output properties as needed
118140 switch (s->format) {
@@ -149,7 +171,7 @@ static void horizontal_frame_pack(AVFilterLink *outlink, · 30 unmodified lines
149171 FramepackContext *s = ctx->priv;
150172 int i, plane;
151173
152− if (interleaved) {
174+ if (interleaved && s->depth <= 8) {
153175 const uint8_t *leftp = s->input_views[LEFT]->data[0];
154176 const uint8_t *rightp = s->input_views[RIGHT]->data[0];
155177 uint8_t *dstp = out->data[0];
@@ -184,17 +206,53 @@ static void horizontal_frame_pack(AVFilterLink *outlink, · 28 unmodified lines
184206 }
185207 }
186208 }
209+ } else if (interleaved && s->depth > 8) {
210+ const uint16_t *leftp = (const uint16_t *)s->input_views[LEFT]->data[0];
211+ const uint16_t *rightp = (const uint16_t *)s->input_views[RIGHT]->data[0];
212+ uint16_t *dstp = (uint16_t *)out->data[0];
213+ int length = out->width / 2;
214+ int lines = out->height;
215+
216+ for (plane = 0; plane < s->pix_desc->nb_components; plane++) {
217+ if (plane == 1 || plane == 2) {
218+ length = AV_CEIL_RSHIFT(out->width / 2, s->pix_desc->log2_chroma_w);
219+ lines = AV_CEIL_RSHIFT(out->height, s->pix_desc->log2_chroma_h);
220+ }
221+ for (i = 0; i < lines; i++) {
222+ int j;
223+ leftp = (const uint16_t *)s->input_views[LEFT]->data[plane] +
224+ s->input_views[LEFT]->linesize[plane] * i / 2;
225+ rightp = (const uint16_t *)s->input_views[RIGHT]->data[plane] +
226+ s->input_views[RIGHT]->linesize[plane] * i / 2;
227+ dstp = (uint16_t *)out->data[plane] + out->linesize[plane] * i / 2;
228+ for (j = 0; j < length; j++) {
229+ // interpolate chroma as necessary
230+ if ((s->pix_desc->log2_chroma_w ||
231+ s->pix_desc->log2_chroma_h) &&
232+ (plane == 1 || plane == 2)) {
233+ *dstp++ = (*leftp + *rightp) / 2;
234+ *dstp++ = (*leftp + *rightp) / 2;
235+ } else {
236+ *dstp++ = *leftp;
237+ *dstp++ = *rightp;
238+ }
239+ leftp += 1;
240+ rightp += 1;
241+ }
242+ }
243+ }
187244 } else {
188245 for (i = 0; i < 2; i++) {
246+ const int psize = 1 + (s->depth > 8);
189247 const uint8_t *src[4];
190248 uint8_t *dst[4];
191− int sub_w = s->input_views[i]->width >> s->pix_desc->log2_chroma_w;
249+ int sub_w = psize * s->input_views[i]->width >> s->pix_desc->log2_chroma_w;
192250
193251 src[0] = s->input_views[i]->data[0];
194252 src[1] = s->input_views[i]->data[1];
195253 src[2] = s->input_views[i]->data[2];
196254
197− dst[0] = out->data[0] + i * s->input_views[i]->width;
255+ dst[0] = out->data[0] + i * s->input_views[i]->width * psize;
198256 dst[1] = out->data[1] + i * sub_w;
199257 dst[2] = out->data[2] + i * sub_w;
200258

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