Commit 84626b36 authored by Anton Khirnov's avatar Anton Khirnov

lavc: add support for codec-specific defaults.

parent 71a861cf
...@@ -2860,6 +2860,8 @@ typedef struct AVProfile { ...@@ -2860,6 +2860,8 @@ typedef struct AVProfile {
const char *name; ///< short name for the profile const char *name; ///< short name for the profile
} AVProfile; } AVProfile;
typedef struct AVCodecDefault AVCodecDefault;
/** /**
* AVCodec. * AVCodec.
*/ */
...@@ -2922,6 +2924,11 @@ typedef struct AVCodec { ...@@ -2922,6 +2924,11 @@ typedef struct AVCodec {
*/ */
int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src); int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
/** @} */ /** @} */
/**
* Private codec-specific defaults.
*/
const AVCodecDefault *defaults;
} AVCodec; } AVCodec;
/** /**
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
#include <stdint.h> #include <stdint.h>
#include "avcodec.h" #include "avcodec.h"
struct AVCodecDefault {
const uint8_t *key;
const uint8_t *value;
};
/** /**
* Determine whether pix_fmt is a hardware accelerated format. * Determine whether pix_fmt is a hardware accelerated format.
*/ */
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
*/ */
#include "avcodec.h" #include "avcodec.h"
#include "internal.h"
#include "libavutil/avassert.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include <float.h> /* FLT_MIN, FLT_MAX */ #include <float.h> /* FLT_MIN, FLT_MAX */
...@@ -524,6 +526,15 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ ...@@ -524,6 +526,15 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){
av_opt_set_defaults(s->priv_data); av_opt_set_defaults(s->priv_data);
} }
} }
if (codec && codec->defaults) {
int ret;
AVCodecDefault *d = codec->defaults;
while (d->key) {
ret = av_set_string3(s, d->key, d->value, 0, NULL);
av_assert0(ret >= 0);
d++;
}
}
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment