summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-12 15:16:53 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-12 15:34:49 +0200
commita33ed6bc74b6b8ada925c76c4084afcf8870a048 (patch)
tree605fa1fc8e55698f892837e7d0191da5e5c34c1c
parentf391e405dfde35bfb3fea9ccc09bd67b5cc0a8f2 (diff)
parentb7f1010c8fce09096057528f7cd29589ea1ae7df (diff)
Merge commit 'b7f1010c8fce09096057528f7cd29589ea1ae7df'
* commit 'b7f1010c8fce09096057528f7cd29589ea1ae7df': tools: do not use av_pix_fmt_descriptors directly. pixdesc: add functions for accessing pixel format descriptors. build: add support for Tru64 (OSF/1) md5: Allocate a normal private context for the opaque md5 context pointer Conflicts: cmdutils.c doc/APIchanges ffprobe.c libavformat/md5enc.c libavutil/version.h tools/graph2dot.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--cmdutils.c16
-rwxr-xr-xconfigure4
-rw-r--r--doc/APIchanges5
-rw-r--r--libavformat/md5enc.c55
-rw-r--r--libavformat/md5proto.c24
-rw-r--r--libavutil/pixdesc.c30
-rw-r--r--libavutil/pixdesc.h23
-rw-r--r--libavutil/version.h5
-rw-r--r--tools/graph2dot.c3
9 files changed, 132 insertions, 33 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 8ef477fd01..2312ca2ac2 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -1094,7 +1094,7 @@ int show_filters(void *optctx, const char *opt, const char *arg)
int show_pix_fmts(void *optctx, const char *opt, const char *arg)
{
- enum AVPixelFormat pix_fmt;
+ const AVPixFmtDescriptor *pix_desc = NULL;
printf("Pixel formats:\n"
"I.... = Supported Input format for conversion\n"
@@ -1110,8 +1110,8 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
# define sws_isSupportedOutput(x) 0
#endif
- for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++) {
- const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt];
+ while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
+ enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
if(!pix_desc->name)
continue;
printf("%c%c%c%c%c %-16s %d %2d\n",
@@ -1484,13 +1484,19 @@ void *grow_array(void *array, int elem_size, int *size, int new_size)
static int alloc_buffer(FrameBuffer **pool, AVCodecContext *s, FrameBuffer **pbuf)
{
- FrameBuffer *buf = av_mallocz(sizeof(*buf));
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
+ FrameBuffer *buf;
int i, ret;
- const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
+ int pixel_size;
int h_chroma_shift, v_chroma_shift;
int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1
int w = s->width, h = s->height;
+ if (!desc)
+ return AVERROR(EINVAL);
+ pixel_size = desc->comp[0].step_minus1 + 1;
+
+ buf = av_mallocz(sizeof(*buf));
if (!buf)
return AVERROR(ENOMEM);
diff --git a/configure b/configure
index a304221b05..cce6aadb8f 100755
--- a/configure
+++ b/configure
@@ -3189,6 +3189,10 @@ case $target_os in
-l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
-l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
;;
+ osf1)
+ add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
+ FFSERVERLDFLAGS=
+ ;;
none)
;;
*)
diff --git a/doc/APIchanges b/doc/APIchanges
index f0f1531215..1d6d34b500 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -97,6 +97,11 @@ API changes, most recent first:
2012-03-26 - a67d9cf - lavfi 2.66.100
Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
+2012-10-12 - xxxxxxx - lavu 51.44.0 - pixdesc.h
+ Add functions for accessing pixel format descriptors.
+ Accessing the av_pix_fmt_descriptors array directly is now
+ deprecated.
+
2012-10-xx - xxxxxxx - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h
Add functions for allocating the opaque contexts for the algorithms,
deprecate the context size variables.
diff --git a/libavformat/md5enc.c b/libavformat/md5enc.c
index f3653084e7..050efb1513 100644
--- a/libavformat/md5enc.c
+++ b/libavformat/md5enc.c
@@ -23,13 +23,16 @@
#include "avformat.h"
#include "internal.h"
-#define PRIVSIZE 512
+struct MD5Context {
+ struct AVMD5 *md5;
+};
static void md5_finish(struct AVFormatContext *s, char *buf)
{
+ struct MD5Context *c = s->priv_data;
uint8_t md5[16];
int i, offset = strlen(buf);
- av_md5_final(s->priv_data, md5);
+ av_md5_final(c->md5, md5);
for (i = 0; i < sizeof(md5); i++) {
snprintf(buf + offset, 3, "%02"PRIx8, md5[i]);
offset += 2;
@@ -44,32 +47,36 @@ static void md5_finish(struct AVFormatContext *s, char *buf)
#if CONFIG_MD5_MUXER
static int write_header(struct AVFormatContext *s)
{
- if (PRIVSIZE < av_md5_size) {
- av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n");
- return -1;
- }
- av_md5_init(s->priv_data);
+ struct MD5Context *c = s->priv_data;
+ c->md5 = av_md5_alloc();
+ if (!c->md5)
+ return AVERROR(ENOMEM);
+ av_md5_init(c->md5);
return 0;
}
static int write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- av_md5_update(s->priv_data, pkt->data, pkt->size);
+ struct MD5Context *c = s->priv_data;
+ av_md5_update(c->md5, pkt->data, pkt->size);
return 0;
}
static int write_trailer(struct AVFormatContext *s)
{
+ struct MD5Context *c = s->priv_data;
char buf[64] = "MD5=";
md5_finish(s, buf);
+
+ av_freep(&c->md5);
return 0;
}
AVOutputFormat ff_md5_muxer = {
.name = "md5",
.long_name = NULL_IF_CONFIG_SMALL("MD5 testing"),
- .priv_data_size = PRIVSIZE,
+ .priv_data_size = sizeof(struct MD5Context),
.audio_codec = AV_CODEC_ID_PCM_S16LE,
.video_codec = AV_CODEC_ID_RAWVIDEO,
.write_header = write_header,
@@ -80,15 +87,21 @@ AVOutputFormat ff_md5_muxer = {
#endif
#if CONFIG_FRAMEMD5_MUXER
+static int framemd5_write_header(struct AVFormatContext *s)
+{
+ struct MD5Context *c = s->priv_data;
+ c->md5 = av_md5_alloc();
+ if (!c->md5)
+ return AVERROR(ENOMEM);
+ return ff_framehash_write_header(s);
+}
+
static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
+ struct MD5Context *c = s->priv_data;
char buf[256];
- if (PRIVSIZE < av_md5_size) {
- av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n");
- return -1;
- }
- av_md5_init(s->priv_data);
- av_md5_update(s->priv_data, pkt->data, pkt->size);
+ av_md5_init(c->md5);
+ av_md5_update(c->md5, pkt->data, pkt->size);
snprintf(buf, sizeof(buf) - 64, "%d, %10"PRId64", %10"PRId64", %8d, %8d, ",
pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size);
@@ -96,14 +109,22 @@ static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt)
return 0;
}
+static int framemd5_write_trailer(struct AVFormatContext *s)
+{
+ struct MD5Context *c = s->priv_data;
+ av_freep(&c->md5);
+ return 0;
+}
+
AVOutputFormat ff_framemd5_muxer = {
.name = "framemd5",
.long_name = NULL_IF_CONFIG_SMALL("Per-frame MD5 testing"),
- .priv_data_size = PRIVSIZE,
+ .priv_data_size = sizeof(struct MD5Context),
.audio_codec = AV_CODEC_ID_PCM_S16LE,
.video_codec = AV_CODEC_ID_RAWVIDEO,
- .write_header = ff_framehash_write_header,
+ .write_header = framemd5_write_header,
.write_packet = framemd5_write_packet,
+ .write_trailer = framemd5_write_trailer,
.flags = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT,
};
#endif
diff --git a/libavformat/md5proto.c b/libavformat/md5proto.c
index f7c8b78fee..6af0a6ed26 100644
--- a/libavformat/md5proto.c
+++ b/libavformat/md5proto.c
@@ -27,37 +27,41 @@
#include "avio.h"
#include "url.h"
-#define PRIV_SIZE 128
+struct MD5Context {
+ struct AVMD5 *md5;
+};
static int md5_open(URLContext *h, const char *filename, int flags)
{
- if (PRIV_SIZE < av_md5_size) {
- av_log(NULL, AV_LOG_ERROR, "Insuffient size for MD5 context\n");
- return -1;
- }
+ struct MD5Context *c = h->priv_data;
if (!(flags & AVIO_FLAG_WRITE))
return AVERROR(EINVAL);
- av_md5_init(h->priv_data);
+ c->md5 = av_md5_alloc();
+ if (!c->md5)
+ return AVERROR(ENOMEM);
+ av_md5_init(c->md5);
return 0;
}
static int md5_write(URLContext *h, const unsigned char *buf, int size)
{
- av_md5_update(h->priv_data, buf, size);
+ struct MD5Context *c = h->priv_data;
+ av_md5_update(c->md5, buf, size);
return size;
}
static int md5_close(URLContext *h)
{
+ struct MD5Context *c = h->priv_data;
const char *filename = h->filename;
uint8_t md5[16], buf[64];
URLContext *out;
int i, err = 0;
- av_md5_final(h->priv_data, md5);
+ av_md5_final(c->md5, md5);
for (i = 0; i < sizeof(md5); i++)
snprintf(buf + i*2, 3, "%02x", md5[i]);
buf[i*2] = '\n';
@@ -76,6 +80,8 @@ static int md5_close(URLContext *h)
err = AVERROR(errno);
}
+ av_freep(&c->md5);
+
return err;
}
@@ -85,5 +91,5 @@ URLProtocol ff_md5_protocol = {
.url_open = md5_open,
.url_write = md5_write,
.url_close = md5_close,
- .priv_data_size = PRIV_SIZE,
+ .priv_data_size = sizeof(struct MD5Context),
};
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 0958718b50..3b5f2643c2 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <string.h>
+
+#include "common.h"
#include "pixfmt.h"
#include "pixdesc.h"
@@ -122,6 +124,9 @@ void av_write_image_line(const uint16_t *src,
}
}
+#if !FF_API_PIX_FMT_DESC
+static
+#endif
const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
[AV_PIX_FMT_YUV420P] = {
.name = "yuv420p",
@@ -1485,3 +1490,28 @@ char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt
return buf;
}
+
+const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
+{
+ if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
+ return NULL;
+ return &av_pix_fmt_descriptors[pix_fmt];
+}
+
+const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
+{
+ if (!prev)
+ return &av_pix_fmt_descriptors[0];
+ if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
+ return prev + 1;
+ return NULL;
+}
+
+enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
+{
+ if (desc < av_pix_fmt_descriptors ||
+ desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
+ return AV_PIX_FMT_NONE;
+
+ return desc - av_pix_fmt_descriptors;
+}
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index 465c215190..ccbee9b2f1 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -99,10 +99,12 @@ typedef struct AVPixFmtDescriptor{
*/
#define PIX_FMT_PSEUDOPAL 64
+#if FF_API_PIX_FMT_DESC
/**
* The array of all the pixel format descriptors.
*/
extern const AVPixFmtDescriptor av_pix_fmt_descriptors[];
+#endif
/**
* Read a line from an image, and write the values of the
@@ -183,4 +185,25 @@ char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt
*/
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
+/**
+ * @return a pixel format descriptor for provided pixel format or NULL if
+ * this pixel format is unknown.
+ */
+const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt);
+
+/**
+ * Iterate over all pixel format descriptors known to libavutil.
+ *
+ * @param prev previous descriptor. NULL to get the first descriptor.
+ *
+ * @return next descriptor or NULL after the last descriptor
+ */
+const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev);
+
+/**
+ * @return an AVPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc
+ * is not a valid pointer to a pixel format descriptor.
+ */
+enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
+
#endif /* AVUTIL_PIXDESC_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 6c313e4202..25dd42dd66 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -39,7 +39,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR 75
+#define LIBAVUTIL_VERSION_MINOR 76
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -87,6 +87,9 @@
#ifndef FF_API_CONTEXT_SIZE
#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52)
#endif
+#ifndef FF_API_PIX_FMT_DESC
+#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 52)
+#endif
/**
* @}
diff --git a/tools/graph2dot.c b/tools/graph2dot.c
index c4a50a8278..4a30beb754 100644
--- a/tools/graph2dot.c
+++ b/tools/graph2dot.c
@@ -82,9 +82,10 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph)
link->srcpad->name, link->dstpad->name);
if (link->type == AVMEDIA_TYPE_VIDEO) {
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
fprintf(outfile,
"fmt:%s w:%d h:%d tb:%d/%d",
- av_pix_fmt_descriptors[link->format].name,
+ desc->name,
link->w, link->h,
link->time_base.num, link->time_base.den);
} else if (link->type == AVMEDIA_TYPE_AUDIO) {