lavc: add avcodec_descriptor_get_by_name().

This commit is contained in:
Anton Khirnov 2012-08-11 15:32:27 +02:00
parent 0a0f19b577
commit 91e59fea30
2 changed files with 19 additions and 0 deletions

View File

@ -4548,6 +4548,12 @@ const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
*/
const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
/**
* @return codec descriptor with the given name or NULL if no such descriptor
* exists.
*/
const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
/**
* @}
*/

View File

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include "avcodec.h"
#include "libavutil/common.h"
@ -1939,3 +1941,14 @@ const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev)
return prev + 1;
return NULL;
}
const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name)
{
const AVCodecDescriptor *desc = NULL;
while ((desc = avcodec_descriptor_next(desc))) {
if (!strcmp(desc->name, name))
return desc;
}
return NULL;
}