summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2012-04-29 11:10:17 +0200
committerNicolas George <nicolas.george@normalesup.org>2012-05-03 18:47:16 +0200
commite296f1b1c4f0b8d4d33f83036a80fd602aca7dea (patch)
tree3ea33fc4d2cc8b9bf5e2663f0b3fd56669ba7c4a /libavcodec/utils.c
parentc1fe2db3769d1a9e2e8d3ea718e4306648bafede (diff)
downloadffmpeg-e296f1b1c4f0b8d4d33f83036a80fd602aca7dea.tar.gz
lavc: implement accessors for some AVFrame fields.
Compared to av_opt_ptr, accessors bring: - better performance (negligible); - compile-time type check; - link-time existence check (or at worst, a dynamic linker error instead of a NULL dereference).
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4b6ddeae1c..71227e942a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -672,6 +672,15 @@ AVFrame *avcodec_alloc_frame(void){
return pic;
}
+#define MAKE_ACCESSORS(str, name, type, field) \
+ type av_##name##_get_##field(const str *s) { return s->field; } \
+ void av_##name##_set_##field(str *s, type v) { s->field = v; }
+
+MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
+MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_pos)
+MAKE_ACCESSORS(AVFrame, frame, int64_t, channel_layout)
+MAKE_ACCESSORS(AVFrame, frame, int, sample_rate)
+
static void avcodec_get_subtitle_defaults(AVSubtitle *sub)
{
memset(sub, 0, sizeof(*sub));