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
44typedef struct FramepackContext {44typedef struct FramepackContext {
45 const AVClass *class;45 const AVClass *class;
46 46
47 int depth;
47 const AVPixFmtDescriptor *pix_desc; ///< agreed pixel format48 const AVPixFmtDescriptor *pix_desc; ///< agreed pixel format
48 49
49 enum AVStereo3DType format; ///< frame pack type output50 enum AVStereo3DType format; ///< frame pack type output
@@ -52,9 +53,29 @@ typedef struct FramepackContext { · 2 unmodified lines
52} FramepackContext;53} FramepackContext;
53 54
54static const enum AVPixelFormat formats_supported[] = {55static const enum AVPixelFormat formats_supported[] = {
55 AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,56 AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9,
56 AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVJ420P,57 AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14,
57 AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,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,
58 AV_PIX_FMT_NONE79 AV_PIX_FMT_NONE
59};80};
60 81
@@ -113,6 +134,7 @@ static int config_output(AVFilterLink *outlink) · 52 unmodified lines
113 s->pix_desc = av_pix_fmt_desc_get(outlink->format);134 s->pix_desc = av_pix_fmt_desc_get(outlink->format);
114 if (!s->pix_desc)135 if (!s->pix_desc)
115 return AVERROR_BUG;136 return AVERROR_BUG;
137 s->depth = s->pix_desc->comp[0].depth;
116 138
117 // modify output properties as needed139 // modify output properties as needed
118 switch (s->format) {140 switch (s->format) {
@@ -149,7 +171,7 @@ static void horizontal_frame_pack(AVFilterLink *outlink, · 30 unmodified lines
149 FramepackContext *s = ctx->priv;171 FramepackContext *s = ctx->priv;
150 int i, plane;172 int i, plane;
151 173
152 if (interleaved) {174 if (interleaved && s->depth <= 8) {
153 const uint8_t *leftp = s->input_views[LEFT]->data[0];175 const uint8_t *leftp = s->input_views[LEFT]->data[0];
154 const uint8_t *rightp = s->input_views[RIGHT]->data[0];176 const uint8_t *rightp = s->input_views[RIGHT]->data[0];
155 uint8_t *dstp = out->data[0];177 uint8_t *dstp = out->data[0];
@@ -184,17 +206,53 @@ static void horizontal_frame_pack(AVFilterLink *outlink, · 28 unmodified lines
184 }206 }
185 }207 }
186 }208 }
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 }
187 } else {244 } else {
188 for (i = 0; i < 2; i++) {245 for (i = 0; i < 2; i++) {
246 const int psize = 1 + (s->depth > 8);
189 const uint8_t *src[4];247 const uint8_t *src[4];
190 uint8_t *dst[4];248 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;
192 250
193 src[0] = s->input_views[i]->data[0];251 src[0] = s->input_views[i]->data[0];
194 src[1] = s->input_views[i]->data[1];252 src[1] = s->input_views[i]->data[1];
195 src[2] = s->input_views[i]->data[2];253 src[2] = s->input_views[i]->data[2];
196 254
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;
198 dst[1] = out->data[1] + i * sub_w;256 dst[1] = out->data[1] + i * sub_w;
199 dst[2] = out->data[2] + i * sub_w;257 dst[2] = out->data[2] + i * sub_w;
200 258

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