00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include "pixfmt.h"
00025 #include "pixdesc.h"
00026
00027 #include "intreadwrite.h"
00028
00029 void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
00030 const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component)
00031 {
00032 AVComponentDescriptor comp= desc->comp[c];
00033 int plane= comp.plane;
00034 int depth= comp.depth_minus1+1;
00035 int mask = (1<<depth)-1;
00036 int shift= comp.shift;
00037 int step = comp.step_minus1+1;
00038 int flags= desc->flags;
00039
00040 if (flags & PIX_FMT_BITSTREAM){
00041 int skip = x*step + comp.offset_plus1-1;
00042 const uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3);
00043 int shift = 8 - depth - (skip&7);
00044
00045 while(w--){
00046 int val = (*p >> shift) & mask;
00047 if(read_pal_component)
00048 val= data[1][4*val + c];
00049 shift -= step;
00050 p -= shift>>3;
00051 shift &= 7;
00052 *dst++= val;
00053 }
00054 } else {
00055 const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
00056 int is_8bit = shift + depth <= 8;
00057
00058 if (is_8bit)
00059 p += !!(flags & PIX_FMT_BE);
00060
00061 while(w--){
00062 int val = is_8bit ? *p :
00063 flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
00064 val = (val>>shift) & mask;
00065 if(read_pal_component)
00066 val= data[1][4*val + c];
00067 p+= step;
00068 *dst++= val;
00069 }
00070 }
00071 }
00072
00073 void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
00074 const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
00075 {
00076 AVComponentDescriptor comp = desc->comp[c];
00077 int plane = comp.plane;
00078 int depth = comp.depth_minus1+1;
00079 int step = comp.step_minus1+1;
00080 int flags = desc->flags;
00081
00082 if (flags & PIX_FMT_BITSTREAM) {
00083 int skip = x*step + comp.offset_plus1-1;
00084 uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3);
00085 int shift = 8 - depth - (skip&7);
00086
00087 while (w--) {
00088 *p |= *src++ << shift;
00089 shift -= step;
00090 p -= shift>>3;
00091 shift &= 7;
00092 }
00093 } else {
00094 int shift = comp.shift;
00095 uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
00096
00097 if (shift + depth <= 8) {
00098 p += !!(flags & PIX_FMT_BE);
00099 while (w--) {
00100 *p |= (*src++<<shift);
00101 p += step;
00102 }
00103 } else {
00104 while (w--) {
00105 if (flags & PIX_FMT_BE) {
00106 uint16_t val = AV_RB16(p) | (*src++<<shift);
00107 AV_WB16(p, val);
00108 } else {
00109 uint16_t val = AV_RL16(p) | (*src++<<shift);
00110 AV_WL16(p, val);
00111 }
00112 p+= step;
00113 }
00114 }
00115 }
00116 }
00117
00118 const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
00119 [PIX_FMT_YUV420P] = {
00120 .name = "yuv420p",
00121 .nb_components= 3,
00122 .log2_chroma_w= 1,
00123 .log2_chroma_h= 1,
00124 .comp = {
00125 {0,0,1,0,7},
00126 {1,0,1,0,7},
00127 {2,0,1,0,7},
00128 },
00129 },
00130 [PIX_FMT_YUYV422] = {
00131 .name = "yuyv422",
00132 .nb_components= 3,
00133 .log2_chroma_w= 1,
00134 .log2_chroma_h= 0,
00135 .comp = {
00136 {0,1,1,0,7},
00137 {0,3,2,0,7},
00138 {0,3,4,0,7},
00139 },
00140 },
00141 [PIX_FMT_RGB24] = {
00142 .name = "rgb24",
00143 .nb_components= 3,
00144 .log2_chroma_w= 0,
00145 .log2_chroma_h= 0,
00146 .comp = {
00147 {0,2,1,0,7},
00148 {0,2,2,0,7},
00149 {0,2,3,0,7},
00150 },
00151 },
00152 [PIX_FMT_BGR24] = {
00153 .name = "bgr24",
00154 .nb_components= 3,
00155 .log2_chroma_w= 0,
00156 .log2_chroma_h= 0,
00157 .comp = {
00158 {0,2,1,0,7},
00159 {0,2,2,0,7},
00160 {0,2,3,0,7},
00161 },
00162 },
00163 [PIX_FMT_YUV422P] = {
00164 .name = "yuv422p",
00165 .nb_components= 3,
00166 .log2_chroma_w= 1,
00167 .log2_chroma_h= 0,
00168 .comp = {
00169 {0,0,1,0,7},
00170 {1,0,1,0,7},
00171 {2,0,1,0,7},
00172 },
00173 },
00174 [PIX_FMT_YUV444P] = {
00175 .name = "yuv444p",
00176 .nb_components= 3,
00177 .log2_chroma_w= 0,
00178 .log2_chroma_h= 0,
00179 .comp = {
00180 {0,0,1,0,7},
00181 {1,0,1,0,7},
00182 {2,0,1,0,7},
00183 },
00184 },
00185 [PIX_FMT_YUV410P] = {
00186 .name = "yuv410p",
00187 .nb_components= 3,
00188 .log2_chroma_w= 2,
00189 .log2_chroma_h= 2,
00190 .comp = {
00191 {0,0,1,0,7},
00192 {1,0,1,0,7},
00193 {2,0,1,0,7},
00194 },
00195 },
00196 [PIX_FMT_YUV411P] = {
00197 .name = "yuv411p",
00198 .nb_components= 3,
00199 .log2_chroma_w= 2,
00200 .log2_chroma_h= 0,
00201 .comp = {
00202 {0,0,1,0,7},
00203 {1,0,1,0,7},
00204 {2,0,1,0,7},
00205 },
00206 },
00207 [PIX_FMT_GRAY8] = {
00208 .name = "gray",
00209 .nb_components= 1,
00210 .log2_chroma_w= 0,
00211 .log2_chroma_h= 0,
00212 .comp = {
00213 {0,0,1,0,7},
00214 },
00215 .flags = PIX_FMT_PAL,
00216 },
00217 [PIX_FMT_MONOWHITE] = {
00218 .name = "monow",
00219 .nb_components= 1,
00220 .log2_chroma_w= 0,
00221 .log2_chroma_h= 0,
00222 .comp = {
00223 {0,0,1,0,0},
00224 },
00225 .flags = PIX_FMT_BITSTREAM,
00226 },
00227 [PIX_FMT_MONOBLACK] = {
00228 .name = "monob",
00229 .nb_components= 1,
00230 .log2_chroma_w= 0,
00231 .log2_chroma_h= 0,
00232 .comp = {
00233 {0,0,1,7,0},
00234 },
00235 .flags = PIX_FMT_BITSTREAM,
00236 },
00237 [PIX_FMT_PAL8] = {
00238 .name = "pal8",
00239 .nb_components= 1,
00240 .log2_chroma_w= 0,
00241 .log2_chroma_h= 0,
00242 .comp = {
00243 {0,0,1,0,7},
00244 },
00245 .flags = PIX_FMT_PAL,
00246 },
00247 [PIX_FMT_YUVJ420P] = {
00248 .name = "yuvj420p",
00249 .nb_components= 3,
00250 .log2_chroma_w= 1,
00251 .log2_chroma_h= 1,
00252 .comp = {
00253 {0,0,1,0,7},
00254 {1,0,1,0,7},
00255 {2,0,1,0,7},
00256 },
00257 },
00258 [PIX_FMT_YUVJ422P] = {
00259 .name = "yuvj422p",
00260 .nb_components= 3,
00261 .log2_chroma_w= 1,
00262 .log2_chroma_h= 0,
00263 .comp = {
00264 {0,0,1,0,7},
00265 {1,0,1,0,7},
00266 {2,0,1,0,7},
00267 },
00268 },
00269 [PIX_FMT_YUVJ444P] = {
00270 .name = "yuvj444p",
00271 .nb_components= 3,
00272 .log2_chroma_w= 0,
00273 .log2_chroma_h= 0,
00274 .comp = {
00275 {0,0,1,0,7},
00276 {1,0,1,0,7},
00277 {2,0,1,0,7},
00278 },
00279 },
00280 [PIX_FMT_XVMC_MPEG2_MC] = {
00281 .name = "xvmcmc",
00282 .flags = PIX_FMT_HWACCEL,
00283 },
00284 [PIX_FMT_XVMC_MPEG2_IDCT] = {
00285 .name = "xvmcidct",
00286 .flags = PIX_FMT_HWACCEL,
00287 },
00288 [PIX_FMT_UYVY422] = {
00289 .name = "uyvy422",
00290 .nb_components= 3,
00291 .log2_chroma_w= 1,
00292 .log2_chroma_h= 0,
00293 .comp = {
00294 {0,1,2,0,7},
00295 {0,3,1,0,7},
00296 {0,3,3,0,7},
00297 },
00298 },
00299 [PIX_FMT_UYYVYY411] = {
00300 .name = "uyyvyy411",
00301 .nb_components= 3,
00302 .log2_chroma_w= 2,
00303 .log2_chroma_h= 0,
00304 .comp = {
00305 {0,3,2,0,7},
00306 {0,5,1,0,7},
00307 {0,5,4,0,7},
00308 },
00309 },
00310 [PIX_FMT_BGR8] = {
00311 .name = "bgr8",
00312 .nb_components= 3,
00313 .log2_chroma_w= 0,
00314 .log2_chroma_h= 0,
00315 .comp = {
00316 {0,0,1,6,1},
00317 {0,0,1,3,2},
00318 {0,0,1,0,2},
00319 },
00320 .flags = PIX_FMT_PAL,
00321 },
00322 [PIX_FMT_BGR4] = {
00323 .name = "bgr4",
00324 .nb_components= 3,
00325 .log2_chroma_w= 0,
00326 .log2_chroma_h= 0,
00327 .comp = {
00328 {0,3,1,0,0},
00329 {0,3,2,0,1},
00330 {0,3,4,0,0},
00331 },
00332 .flags = PIX_FMT_BITSTREAM,
00333 },
00334 [PIX_FMT_BGR4_BYTE] = {
00335 .name = "bgr4_byte",
00336 .nb_components= 3,
00337 .log2_chroma_w= 0,
00338 .log2_chroma_h= 0,
00339 .comp = {
00340 {0,0,1,3,0},
00341 {0,0,1,1,1},
00342 {0,0,1,0,0},
00343 },
00344 .flags = PIX_FMT_PAL,
00345 },
00346 [PIX_FMT_RGB8] = {
00347 .name = "rgb8",
00348 .nb_components= 3,
00349 .log2_chroma_w= 0,
00350 .log2_chroma_h= 0,
00351 .comp = {
00352 {0,0,1,6,1},
00353 {0,0,1,3,2},
00354 {0,0,1,0,2},
00355 },
00356 .flags = PIX_FMT_PAL,
00357 },
00358 [PIX_FMT_RGB4] = {
00359 .name = "rgb4",
00360 .nb_components= 3,
00361 .log2_chroma_w= 0,
00362 .log2_chroma_h= 0,
00363 .comp = {
00364 {0,3,1,0,0},
00365 {0,3,2,0,1},
00366 {0,3,4,0,0},
00367 },
00368 .flags = PIX_FMT_BITSTREAM,
00369 },
00370 [PIX_FMT_RGB4_BYTE] = {
00371 .name = "rgb4_byte",
00372 .nb_components= 3,
00373 .log2_chroma_w= 0,
00374 .log2_chroma_h= 0,
00375 .comp = {
00376 {0,0,1,3,0},
00377 {0,0,1,1,1},
00378 {0,0,1,0,0},
00379 },
00380 .flags = PIX_FMT_PAL,
00381 },
00382 [PIX_FMT_NV12] = {
00383 .name = "nv12",
00384 .nb_components= 3,
00385 .log2_chroma_w= 1,
00386 .log2_chroma_h= 1,
00387 .comp = {
00388 {0,0,1,0,7},
00389 {1,1,1,0,7},
00390 {1,1,2,0,7},
00391 },
00392 },
00393 [PIX_FMT_NV21] = {
00394 .name = "nv21",
00395 .nb_components= 3,
00396 .log2_chroma_w= 1,
00397 .log2_chroma_h= 1,
00398 .comp = {
00399 {0,0,1,0,7},
00400 {1,1,1,0,7},
00401 {1,1,2,0,7},
00402 },
00403 },
00404 [PIX_FMT_ARGB] = {
00405 .name = "argb",
00406 .nb_components= 4,
00407 .log2_chroma_w= 0,
00408 .log2_chroma_h= 0,
00409 .comp = {
00410 {0,3,1,0,7},
00411 {0,3,2,0,7},
00412 {0,3,3,0,7},
00413 {0,3,4,0,7},
00414 },
00415 },
00416 [PIX_FMT_RGBA] = {
00417 .name = "rgba",
00418 .nb_components= 4,
00419 .log2_chroma_w= 0,
00420 .log2_chroma_h= 0,
00421 .comp = {
00422 {0,3,1,0,7},
00423 {0,3,2,0,7},
00424 {0,3,3,0,7},
00425 {0,3,4,0,7},
00426 },
00427 },
00428 [PIX_FMT_ABGR] = {
00429 .name = "abgr",
00430 .nb_components= 4,
00431 .log2_chroma_w= 0,
00432 .log2_chroma_h= 0,
00433 .comp = {
00434 {0,3,1,0,7},
00435 {0,3,2,0,7},
00436 {0,3,3,0,7},
00437 {0,3,4,0,7},
00438 },
00439 },
00440 [PIX_FMT_BGRA] = {
00441 .name = "bgra",
00442 .nb_components= 4,
00443 .log2_chroma_w= 0,
00444 .log2_chroma_h= 0,
00445 .comp = {
00446 {0,3,1,0,7},
00447 {0,3,2,0,7},
00448 {0,3,3,0,7},
00449 {0,3,4,0,7},
00450 },
00451 },
00452 [PIX_FMT_GRAY16BE] = {
00453 .name = "gray16be",
00454 .nb_components= 1,
00455 .log2_chroma_w= 0,
00456 .log2_chroma_h= 0,
00457 .comp = {
00458 {0,1,1,0,15},
00459 },
00460 .flags = PIX_FMT_BE,
00461 },
00462 [PIX_FMT_GRAY16LE] = {
00463 .name = "gray16le",
00464 .nb_components= 1,
00465 .log2_chroma_w= 0,
00466 .log2_chroma_h= 0,
00467 .comp = {
00468 {0,1,1,0,15},
00469 },
00470 },
00471 [PIX_FMT_YUV440P] = {
00472 .name = "yuv440p",
00473 .nb_components= 3,
00474 .log2_chroma_w= 0,
00475 .log2_chroma_h= 1,
00476 .comp = {
00477 {0,0,1,0,7},
00478 {1,0,1,0,7},
00479 {2,0,1,0,7},
00480 },
00481 },
00482 [PIX_FMT_YUVJ440P] = {
00483 .name = "yuvj440p",
00484 .nb_components= 3,
00485 .log2_chroma_w= 0,
00486 .log2_chroma_h= 1,
00487 .comp = {
00488 {0,0,1,0,7},
00489 {1,0,1,0,7},
00490 {2,0,1,0,7},
00491 },
00492 },
00493 [PIX_FMT_YUVA420P] = {
00494 .name = "yuva420p",
00495 .nb_components= 4,
00496 .log2_chroma_w= 1,
00497 .log2_chroma_h= 1,
00498 .comp = {
00499 {0,0,1,0,7},
00500 {1,0,1,0,7},
00501 {2,0,1,0,7},
00502 {3,0,1,0,7},
00503 },
00504 },
00505 [PIX_FMT_VDPAU_H264] = {
00506 .name = "vdpau_h264",
00507 .log2_chroma_w = 1,
00508 .log2_chroma_h = 1,
00509 .flags = PIX_FMT_HWACCEL,
00510 },
00511 [PIX_FMT_VDPAU_MPEG1] = {
00512 .name = "vdpau_mpeg1",
00513 .log2_chroma_w = 1,
00514 .log2_chroma_h = 1,
00515 .flags = PIX_FMT_HWACCEL,
00516 },
00517 [PIX_FMT_VDPAU_MPEG2] = {
00518 .name = "vdpau_mpeg2",
00519 .log2_chroma_w = 1,
00520 .log2_chroma_h = 1,
00521 .flags = PIX_FMT_HWACCEL,
00522 },
00523 [PIX_FMT_VDPAU_WMV3] = {
00524 .name = "vdpau_wmv3",
00525 .log2_chroma_w = 1,
00526 .log2_chroma_h = 1,
00527 .flags = PIX_FMT_HWACCEL,
00528 },
00529 [PIX_FMT_VDPAU_VC1] = {
00530 .name = "vdpau_vc1",
00531 .log2_chroma_w = 1,
00532 .log2_chroma_h = 1,
00533 .flags = PIX_FMT_HWACCEL,
00534 },
00535 [PIX_FMT_VDPAU_MPEG4] = {
00536 .name = "vdpau_mpeg4",
00537 .log2_chroma_w = 1,
00538 .log2_chroma_h = 1,
00539 .flags = PIX_FMT_HWACCEL,
00540 },
00541 [PIX_FMT_RGB48BE] = {
00542 .name = "rgb48be",
00543 .nb_components= 3,
00544 .log2_chroma_w= 0,
00545 .log2_chroma_h= 0,
00546 .comp = {
00547 {0,5,1,0,15},
00548 {0,5,3,0,15},
00549 {0,5,5,0,15},
00550 },
00551 .flags = PIX_FMT_BE,
00552 },
00553 [PIX_FMT_RGB48LE] = {
00554 .name = "rgb48le",
00555 .nb_components= 3,
00556 .log2_chroma_w= 0,
00557 .log2_chroma_h= 0,
00558 .comp = {
00559 {0,5,1,0,15},
00560 {0,5,3,0,15},
00561 {0,5,5,0,15},
00562 },
00563 },
00564 [PIX_FMT_RGB565BE] = {
00565 .name = "rgb565be",
00566 .nb_components= 3,
00567 .log2_chroma_w= 0,
00568 .log2_chroma_h= 0,
00569 .comp = {
00570 {0,1,0,3,4},
00571 {0,1,1,5,5},
00572 {0,1,1,0,4},
00573 },
00574 .flags = PIX_FMT_BE,
00575 },
00576 [PIX_FMT_RGB565LE] = {
00577 .name = "rgb565le",
00578 .nb_components= 3,
00579 .log2_chroma_w= 0,
00580 .log2_chroma_h= 0,
00581 .comp = {
00582 {0,1,2,3,4},
00583 {0,1,1,5,5},
00584 {0,1,1,0,4},
00585 },
00586 },
00587 [PIX_FMT_RGB555BE] = {
00588 .name = "rgb555be",
00589 .nb_components= 3,
00590 .log2_chroma_w= 0,
00591 .log2_chroma_h= 0,
00592 .comp = {
00593 {0,1,0,2,4},
00594 {0,1,1,5,4},
00595 {0,1,1,0,4},
00596 },
00597 .flags = PIX_FMT_BE,
00598 },
00599 [PIX_FMT_RGB555LE] = {
00600 .name = "rgb555le",
00601 .nb_components= 3,
00602 .log2_chroma_w= 0,
00603 .log2_chroma_h= 0,
00604 .comp = {
00605 {0,1,2,2,4},
00606 {0,1,1,5,4},
00607 {0,1,1,0,4},
00608 },
00609 },
00610 [PIX_FMT_RGB444BE] = {
00611 .name = "rgb444be",
00612 .nb_components= 3,
00613 .log2_chroma_w= 0,
00614 .log2_chroma_h= 0,
00615 .comp = {
00616 {0,1,0,0,3},
00617 {0,1,1,4,3},
00618 {0,1,1,0,3},
00619 },
00620 .flags = PIX_FMT_BE,
00621 },
00622 [PIX_FMT_RGB444LE] = {
00623 .name = "rgb444le",
00624 .nb_components= 3,
00625 .log2_chroma_w= 0,
00626 .log2_chroma_h= 0,
00627 .comp = {
00628 {0,1,2,0,3},
00629 {0,1,1,4,3},
00630 {0,1,1,0,3},
00631 },
00632 },
00633 [PIX_FMT_BGR48BE] = {
00634 .name = "bgr48be",
00635 .nb_components= 3,
00636 .log2_chroma_w= 0,
00637 .log2_chroma_h= 0,
00638 .comp = {
00639 {0,5,1,0,15},
00640 {0,5,3,0,15},
00641 {0,5,5,0,15},
00642 },
00643 .flags = PIX_FMT_BE,
00644 },
00645 [PIX_FMT_BGR48LE] = {
00646 .name = "bgr48le",
00647 .nb_components= 3,
00648 .log2_chroma_w= 0,
00649 .log2_chroma_h= 0,
00650 .comp = {
00651 {0,5,1,0,15},
00652 {0,5,3,0,15},
00653 {0,5,5,0,15},
00654 },
00655 },
00656 [PIX_FMT_BGR565BE] = {
00657 .name = "bgr565be",
00658 .nb_components= 3,
00659 .log2_chroma_w= 0,
00660 .log2_chroma_h= 0,
00661 .comp = {
00662 {0,1,0,3,4},
00663 {0,1,1,5,5},
00664 {0,1,1,0,4},
00665 },
00666 .flags = PIX_FMT_BE,
00667 },
00668 [PIX_FMT_BGR565LE] = {
00669 .name = "bgr565le",
00670 .nb_components= 3,
00671 .log2_chroma_w= 0,
00672 .log2_chroma_h= 0,
00673 .comp = {
00674 {0,1,2,3,4},
00675 {0,1,1,5,5},
00676 {0,1,1,0,4},
00677 },
00678 },
00679 [PIX_FMT_BGR555BE] = {
00680 .name = "bgr555be",
00681 .nb_components= 3,
00682 .log2_chroma_w= 0,
00683 .log2_chroma_h= 0,
00684 .comp = {
00685 {0,1,0,2,4},
00686 {0,1,1,5,4},
00687 {0,1,1,0,4},
00688 },
00689 .flags = PIX_FMT_BE,
00690 },
00691 [PIX_FMT_BGR555LE] = {
00692 .name = "bgr555le",
00693 .nb_components= 3,
00694 .log2_chroma_w= 0,
00695 .log2_chroma_h= 0,
00696 .comp = {
00697 {0,1,2,2,4},
00698 {0,1,1,5,4},
00699 {0,1,1,0,4},
00700 },
00701 },
00702 [PIX_FMT_BGR444BE] = {
00703 .name = "bgr444be",
00704 .nb_components= 3,
00705 .log2_chroma_w= 0,
00706 .log2_chroma_h= 0,
00707 .comp = {
00708 {0,1,0,0,3},
00709 {0,1,1,4,3},
00710 {0,1,1,0,3},
00711 },
00712 .flags = PIX_FMT_BE,
00713 },
00714 [PIX_FMT_BGR444LE] = {
00715 .name = "bgr444le",
00716 .nb_components= 3,
00717 .log2_chroma_w= 0,
00718 .log2_chroma_h= 0,
00719 .comp = {
00720 {0,1,2,0,3},
00721 {0,1,1,4,3},
00722 {0,1,1,0,3},
00723 },
00724 },
00725 [PIX_FMT_VAAPI_MOCO] = {
00726 .name = "vaapi_moco",
00727 .log2_chroma_w = 1,
00728 .log2_chroma_h = 1,
00729 .flags = PIX_FMT_HWACCEL,
00730 },
00731 [PIX_FMT_VAAPI_IDCT] = {
00732 .name = "vaapi_idct",
00733 .log2_chroma_w = 1,
00734 .log2_chroma_h = 1,
00735 .flags = PIX_FMT_HWACCEL,
00736 },
00737 [PIX_FMT_VAAPI_VLD] = {
00738 .name = "vaapi_vld",
00739 .log2_chroma_w = 1,
00740 .log2_chroma_h = 1,
00741 .flags = PIX_FMT_HWACCEL,
00742 },
00743 [PIX_FMT_YUV420P9LE] = {
00744 .name = "yuv420p9le",
00745 .nb_components= 3,
00746 .log2_chroma_w= 1,
00747 .log2_chroma_h= 1,
00748 .comp = {
00749 {0,1,1,0,8},
00750 {1,1,1,0,8},
00751 {2,1,1,0,8},
00752 },
00753 },
00754 [PIX_FMT_YUV420P9BE] = {
00755 .name = "yuv420p9be",
00756 .nb_components= 3,
00757 .log2_chroma_w= 1,
00758 .log2_chroma_h= 1,
00759 .comp = {
00760 {0,1,1,0,8},
00761 {1,1,1,0,8},
00762 {2,1,1,0,8},
00763 },
00764 .flags = PIX_FMT_BE,
00765 },
00766 [PIX_FMT_YUV420P10LE] = {
00767 .name = "yuv420p10le",
00768 .nb_components= 3,
00769 .log2_chroma_w= 1,
00770 .log2_chroma_h= 1,
00771 .comp = {
00772 {0,1,1,0,9},
00773 {1,1,1,0,9},
00774 {2,1,1,0,9},
00775 },
00776 },
00777 [PIX_FMT_YUV420P10BE] = {
00778 .name = "yuv420p10be",
00779 .nb_components= 3,
00780 .log2_chroma_w= 1,
00781 .log2_chroma_h= 1,
00782 .comp = {
00783 {0,1,1,0,9},
00784 {1,1,1,0,9},
00785 {2,1,1,0,9},
00786 },
00787 .flags = PIX_FMT_BE,
00788 },
00789 [PIX_FMT_YUV420P16LE] = {
00790 .name = "yuv420p16le",
00791 .nb_components= 3,
00792 .log2_chroma_w= 1,
00793 .log2_chroma_h= 1,
00794 .comp = {
00795 {0,1,1,0,15},
00796 {1,1,1,0,15},
00797 {2,1,1,0,15},
00798 },
00799 },
00800 [PIX_FMT_YUV420P16BE] = {
00801 .name = "yuv420p16be",
00802 .nb_components= 3,
00803 .log2_chroma_w= 1,
00804 .log2_chroma_h= 1,
00805 .comp = {
00806 {0,1,1,0,15},
00807 {1,1,1,0,15},
00808 {2,1,1,0,15},
00809 },
00810 .flags = PIX_FMT_BE,
00811 },
00812 [PIX_FMT_YUV422P10LE] = {
00813 .name = "yuv422p10le",
00814 .nb_components= 3,
00815 .log2_chroma_w= 1,
00816 .log2_chroma_h= 0,
00817 .comp = {
00818 {0,1,1,0,9},
00819 {1,1,1,0,9},
00820 {2,1,1,0,9},
00821 },
00822 },
00823 [PIX_FMT_YUV422P10BE] = {
00824 .name = "yuv422p10be",
00825 .nb_components= 3,
00826 .log2_chroma_w= 1,
00827 .log2_chroma_h= 0,
00828 .comp = {
00829 {0,1,1,0,9},
00830 {1,1,1,0,9},
00831 {2,1,1,0,9},
00832 },
00833 .flags = PIX_FMT_BE,
00834 },
00835 [PIX_FMT_YUV422P16LE] = {
00836 .name = "yuv422p16le",
00837 .nb_components= 3,
00838 .log2_chroma_w= 1,
00839 .log2_chroma_h= 0,
00840 .comp = {
00841 {0,1,1,0,15},
00842 {1,1,1,0,15},
00843 {2,1,1,0,15},
00844 },
00845 },
00846 [PIX_FMT_YUV422P16BE] = {
00847 .name = "yuv422p16be",
00848 .nb_components= 3,
00849 .log2_chroma_w= 1,
00850 .log2_chroma_h= 0,
00851 .comp = {
00852 {0,1,1,0,15},
00853 {1,1,1,0,15},
00854 {2,1,1,0,15},
00855 },
00856 .flags = PIX_FMT_BE,
00857 },
00858 [PIX_FMT_YUV444P16LE] = {
00859 .name = "yuv444p16le",
00860 .nb_components= 3,
00861 .log2_chroma_w= 0,
00862 .log2_chroma_h= 0,
00863 .comp = {
00864 {0,1,1,0,15},
00865 {1,1,1,0,15},
00866 {2,1,1,0,15},
00867 },
00868 },
00869 [PIX_FMT_YUV444P16BE] = {
00870 .name = "yuv444p16be",
00871 .nb_components= 3,
00872 .log2_chroma_w= 0,
00873 .log2_chroma_h= 0,
00874 .comp = {
00875 {0,1,1,0,15},
00876 {1,1,1,0,15},
00877 {2,1,1,0,15},
00878 },
00879 .flags = PIX_FMT_BE,
00880 },
00881 [PIX_FMT_YUV444P10LE] = {
00882 .name = "yuv444p10le",
00883 .nb_components= 3,
00884 .log2_chroma_w= 0,
00885 .log2_chroma_h= 0,
00886 .comp = {
00887 {0,1,1,0,9},
00888 {1,1,1,0,9},
00889 {2,1,1,0,9},
00890 },
00891 },
00892 [PIX_FMT_YUV444P10BE] = {
00893 .name = "yuv444p10be",
00894 .nb_components= 3,
00895 .log2_chroma_w= 0,
00896 .log2_chroma_h= 0,
00897 .comp = {
00898 {0,1,1,0,9},
00899 {1,1,1,0,9},
00900 {2,1,1,0,9},
00901 },
00902 .flags = PIX_FMT_BE,
00903 },
00904 [PIX_FMT_YUV444P9LE] = {
00905 .name = "yuv444p9le",
00906 .nb_components= 3,
00907 .log2_chroma_w= 0,
00908 .log2_chroma_h= 0,
00909 .comp = {
00910 {0,1,1,0,8},
00911 {1,1,1,0,8},
00912 {2,1,1,0,8},
00913 },
00914 },
00915 [PIX_FMT_YUV444P9BE] = {
00916 .name = "yuv444p9be",
00917 .nb_components= 3,
00918 .log2_chroma_w= 0,
00919 .log2_chroma_h= 0,
00920 .comp = {
00921 {0,1,1,0,8},
00922 {1,1,1,0,8},
00923 {2,1,1,0,8},
00924 },
00925 .flags = PIX_FMT_BE,
00926 },
00927 [PIX_FMT_DXVA2_VLD] = {
00928 .name = "dxva2_vld",
00929 .log2_chroma_w = 1,
00930 .log2_chroma_h = 1,
00931 .flags = PIX_FMT_HWACCEL,
00932 },
00933 [PIX_FMT_GRAY8A] = {
00934 .name = "gray8a",
00935 .nb_components= 2,
00936 .comp = {
00937 {0,1,1,0,7},
00938 {0,1,2,0,7},
00939 },
00940 },
00941 };
00942
00943 static enum PixelFormat get_pix_fmt_internal(const char *name)
00944 {
00945 enum PixelFormat pix_fmt;
00946
00947 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
00948 if (av_pix_fmt_descriptors[pix_fmt].name &&
00949 !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
00950 return pix_fmt;
00951
00952 return PIX_FMT_NONE;
00953 }
00954
00955 const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
00956 {
00957 return (unsigned)pix_fmt < PIX_FMT_NB ?
00958 av_pix_fmt_descriptors[pix_fmt].name : NULL;
00959 }
00960
00961 #if HAVE_BIGENDIAN
00962 # define X_NE(be, le) be
00963 #else
00964 # define X_NE(be, le) le
00965 #endif
00966
00967 enum PixelFormat av_get_pix_fmt(const char *name)
00968 {
00969 enum PixelFormat pix_fmt;
00970
00971 if (!strcmp(name, "rgb32"))
00972 name = X_NE("argb", "bgra");
00973 else if (!strcmp(name, "bgr32"))
00974 name = X_NE("abgr", "rgba");
00975
00976 pix_fmt = get_pix_fmt_internal(name);
00977 if (pix_fmt == PIX_FMT_NONE) {
00978 char name2[32];
00979
00980 snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
00981 pix_fmt = get_pix_fmt_internal(name2);
00982 }
00983 return pix_fmt;
00984 }
00985
00986 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
00987 {
00988 int c, bits = 0;
00989 int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
00990
00991 for (c = 0; c < pixdesc->nb_components; c++) {
00992 int s = c==1 || c==2 ? 0 : log2_pixels;
00993 bits += (pixdesc->comp[c].depth_minus1+1) << s;
00994 }
00995
00996 return bits >> log2_pixels;
00997 }
00998
00999 char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
01000 {
01001
01002 if (pix_fmt < 0) {
01003 snprintf (buf, buf_size, "name " " nb_components" " nb_bits");
01004 } else {
01005 const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
01006 snprintf(buf, buf_size, "%-11s %7d %10d",
01007 pixdesc->name, pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
01008 }
01009
01010 return buf;
01011 }