Mercurial > libavcodec.hg
comparison imgconvert.c @ 9222:e314914641bc libavcodec
Extend the behavior of avcodec_get_pix_fmt(), if it cannot find a
pixel format for the provided name, make it look for the native endian
variant of the name.
author | stefano |
---|---|
date | Sat, 21 Mar 2009 22:43:46 +0000 |
parents | a15ec86bf752 |
children | 53f2c0f6e71d |
comparison
equal
deleted
inserted
replaced
9221:a15ec86bf752 | 9222:e314914641bc |
---|---|
455 return NULL; | 455 return NULL; |
456 else | 456 else |
457 return pix_fmt_info[pix_fmt].name; | 457 return pix_fmt_info[pix_fmt].name; |
458 } | 458 } |
459 | 459 |
460 enum PixelFormat avcodec_get_pix_fmt(const char* name) | 460 static enum PixelFormat avcodec_get_pix_fmt_internal(const char *name) |
461 { | 461 { |
462 int i; | 462 int i; |
463 | 463 |
464 for (i=0; i < PIX_FMT_NB; i++) | 464 for (i=0; i < PIX_FMT_NB; i++) |
465 if (!strcmp(pix_fmt_info[i].name, name)) | 465 if (!strcmp(pix_fmt_info[i].name, name)) |
466 return i; | 466 return i; |
467 return PIX_FMT_NONE; | 467 return PIX_FMT_NONE; |
468 } | |
469 | |
470 enum PixelFormat avcodec_get_pix_fmt(const char *name) | |
471 { | |
472 #ifdef WORDS_BIGENDIAN | |
473 # define NE "be" | |
474 #else | |
475 # define NE "le" | |
476 #endif | |
477 enum PixelFormat pix_fmt = avcodec_get_pix_fmt_internal(name); | |
478 | |
479 if (pix_fmt == PIX_FMT_NONE) { | |
480 char name2[32]; | |
481 snprintf(name2, sizeof(name2), "%s%s", name, NE); | |
482 pix_fmt = avcodec_get_pix_fmt_internal(name2); | |
483 } | |
484 return pix_fmt; | |
485 #undef NE | |
468 } | 486 } |
469 | 487 |
470 void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) | 488 void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) |
471 { | 489 { |
472 /* print header */ | 490 /* print header */ |