* 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>
... | ... |
@@ -1094,7 +1094,7 @@ int show_filters(void *optctx, const char *opt, const char *arg) |
1094 | 1094 |
|
1095 | 1095 |
int show_pix_fmts(void *optctx, const char *opt, const char *arg) |
1096 | 1096 |
{ |
1097 |
- enum AVPixelFormat pix_fmt; |
|
1097 |
+ const AVPixFmtDescriptor *pix_desc = NULL; |
|
1098 | 1098 |
|
1099 | 1099 |
printf("Pixel formats:\n" |
1100 | 1100 |
"I.... = Supported Input format for conversion\n" |
... | ... |
@@ -1110,8 +1110,8 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg) |
1110 | 1110 |
# define sws_isSupportedOutput(x) 0 |
1111 | 1111 |
#endif |
1112 | 1112 |
|
1113 |
- for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++) { |
|
1114 |
- const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt]; |
|
1113 |
+ while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) { |
|
1114 |
+ enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc); |
|
1115 | 1115 |
if(!pix_desc->name) |
1116 | 1116 |
continue; |
1117 | 1117 |
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) |
1484 | 1484 |
|
1485 | 1485 |
static int alloc_buffer(FrameBuffer **pool, AVCodecContext *s, FrameBuffer **pbuf) |
1486 | 1486 |
{ |
1487 |
- FrameBuffer *buf = av_mallocz(sizeof(*buf)); |
|
1487 |
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt); |
|
1488 |
+ FrameBuffer *buf; |
|
1488 | 1489 |
int i, ret; |
1489 |
- const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; |
|
1490 |
+ int pixel_size; |
|
1490 | 1491 |
int h_chroma_shift, v_chroma_shift; |
1491 | 1492 |
int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1 |
1492 | 1493 |
int w = s->width, h = s->height; |
1493 | 1494 |
|
1495 |
+ if (!desc) |
|
1496 |
+ return AVERROR(EINVAL); |
|
1497 |
+ pixel_size = desc->comp[0].step_minus1 + 1; |
|
1498 |
+ |
|
1499 |
+ buf = av_mallocz(sizeof(*buf)); |
|
1494 | 1500 |
if (!buf) |
1495 | 1501 |
return AVERROR(ENOMEM); |
1496 | 1502 |
|
... | ... |
@@ -3189,6 +3189,10 @@ case $target_os in |
3189 | 3189 |
-l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \ |
3190 | 3190 |
-l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib |
3191 | 3191 |
;; |
3192 |
+ osf1) |
|
3193 |
+ add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT |
|
3194 |
+ FFSERVERLDFLAGS= |
|
3195 |
+ ;; |
|
3192 | 3196 |
none) |
3193 | 3197 |
;; |
3194 | 3198 |
*) |
... | ... |
@@ -97,6 +97,11 @@ API changes, most recent first: |
97 | 97 |
2012-03-26 - a67d9cf - lavfi 2.66.100 |
98 | 98 |
Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. |
99 | 99 |
|
100 |
+2012-10-12 - xxxxxxx - lavu 51.44.0 - pixdesc.h |
|
101 |
+ Add functions for accessing pixel format descriptors. |
|
102 |
+ Accessing the av_pix_fmt_descriptors array directly is now |
|
103 |
+ deprecated. |
|
104 |
+ |
|
100 | 105 |
2012-10-xx - xxxxxxx - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h |
101 | 106 |
Add functions for allocating the opaque contexts for the algorithms, |
102 | 107 |
deprecate the context size variables. |
... | ... |
@@ -23,13 +23,16 @@ |
23 | 23 |
#include "avformat.h" |
24 | 24 |
#include "internal.h" |
25 | 25 |
|
26 |
-#define PRIVSIZE 512 |
|
26 |
+struct MD5Context { |
|
27 |
+ struct AVMD5 *md5; |
|
28 |
+}; |
|
27 | 29 |
|
28 | 30 |
static void md5_finish(struct AVFormatContext *s, char *buf) |
29 | 31 |
{ |
32 |
+ struct MD5Context *c = s->priv_data; |
|
30 | 33 |
uint8_t md5[16]; |
31 | 34 |
int i, offset = strlen(buf); |
32 |
- av_md5_final(s->priv_data, md5); |
|
35 |
+ av_md5_final(c->md5, md5); |
|
33 | 36 |
for (i = 0; i < sizeof(md5); i++) { |
34 | 37 |
snprintf(buf + offset, 3, "%02"PRIx8, md5[i]); |
35 | 38 |
offset += 2; |
... | ... |
@@ -44,32 +47,36 @@ static void md5_finish(struct AVFormatContext *s, char *buf) |
44 | 44 |
#if CONFIG_MD5_MUXER |
45 | 45 |
static int write_header(struct AVFormatContext *s) |
46 | 46 |
{ |
47 |
- if (PRIVSIZE < av_md5_size) { |
|
48 |
- av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n"); |
|
49 |
- return -1; |
|
50 |
- } |
|
51 |
- av_md5_init(s->priv_data); |
|
47 |
+ struct MD5Context *c = s->priv_data; |
|
48 |
+ c->md5 = av_md5_alloc(); |
|
49 |
+ if (!c->md5) |
|
50 |
+ return AVERROR(ENOMEM); |
|
51 |
+ av_md5_init(c->md5); |
|
52 | 52 |
return 0; |
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
static int write_packet(struct AVFormatContext *s, AVPacket *pkt) |
56 | 56 |
{ |
57 |
- av_md5_update(s->priv_data, pkt->data, pkt->size); |
|
57 |
+ struct MD5Context *c = s->priv_data; |
|
58 |
+ av_md5_update(c->md5, pkt->data, pkt->size); |
|
58 | 59 |
return 0; |
59 | 60 |
} |
60 | 61 |
|
61 | 62 |
static int write_trailer(struct AVFormatContext *s) |
62 | 63 |
{ |
64 |
+ struct MD5Context *c = s->priv_data; |
|
63 | 65 |
char buf[64] = "MD5="; |
64 | 66 |
|
65 | 67 |
md5_finish(s, buf); |
68 |
+ |
|
69 |
+ av_freep(&c->md5); |
|
66 | 70 |
return 0; |
67 | 71 |
} |
68 | 72 |
|
69 | 73 |
AVOutputFormat ff_md5_muxer = { |
70 | 74 |
.name = "md5", |
71 | 75 |
.long_name = NULL_IF_CONFIG_SMALL("MD5 testing"), |
72 |
- .priv_data_size = PRIVSIZE, |
|
76 |
+ .priv_data_size = sizeof(struct MD5Context), |
|
73 | 77 |
.audio_codec = AV_CODEC_ID_PCM_S16LE, |
74 | 78 |
.video_codec = AV_CODEC_ID_RAWVIDEO, |
75 | 79 |
.write_header = write_header, |
... | ... |
@@ -80,15 +87,21 @@ AVOutputFormat ff_md5_muxer = { |
80 | 80 |
#endif |
81 | 81 |
|
82 | 82 |
#if CONFIG_FRAMEMD5_MUXER |
83 |
+static int framemd5_write_header(struct AVFormatContext *s) |
|
84 |
+{ |
|
85 |
+ struct MD5Context *c = s->priv_data; |
|
86 |
+ c->md5 = av_md5_alloc(); |
|
87 |
+ if (!c->md5) |
|
88 |
+ return AVERROR(ENOMEM); |
|
89 |
+ return ff_framehash_write_header(s); |
|
90 |
+} |
|
91 |
+ |
|
83 | 92 |
static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt) |
84 | 93 |
{ |
94 |
+ struct MD5Context *c = s->priv_data; |
|
85 | 95 |
char buf[256]; |
86 |
- if (PRIVSIZE < av_md5_size) { |
|
87 |
- av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n"); |
|
88 |
- return -1; |
|
89 |
- } |
|
90 |
- av_md5_init(s->priv_data); |
|
91 |
- av_md5_update(s->priv_data, pkt->data, pkt->size); |
|
96 |
+ av_md5_init(c->md5); |
|
97 |
+ av_md5_update(c->md5, pkt->data, pkt->size); |
|
92 | 98 |
|
93 | 99 |
snprintf(buf, sizeof(buf) - 64, "%d, %10"PRId64", %10"PRId64", %8d, %8d, ", |
94 | 100 |
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) |
96 | 96 |
return 0; |
97 | 97 |
} |
98 | 98 |
|
99 |
+static int framemd5_write_trailer(struct AVFormatContext *s) |
|
100 |
+{ |
|
101 |
+ struct MD5Context *c = s->priv_data; |
|
102 |
+ av_freep(&c->md5); |
|
103 |
+ return 0; |
|
104 |
+} |
|
105 |
+ |
|
99 | 106 |
AVOutputFormat ff_framemd5_muxer = { |
100 | 107 |
.name = "framemd5", |
101 | 108 |
.long_name = NULL_IF_CONFIG_SMALL("Per-frame MD5 testing"), |
102 |
- .priv_data_size = PRIVSIZE, |
|
109 |
+ .priv_data_size = sizeof(struct MD5Context), |
|
103 | 110 |
.audio_codec = AV_CODEC_ID_PCM_S16LE, |
104 | 111 |
.video_codec = AV_CODEC_ID_RAWVIDEO, |
105 |
- .write_header = ff_framehash_write_header, |
|
112 |
+ .write_header = framemd5_write_header, |
|
106 | 113 |
.write_packet = framemd5_write_packet, |
114 |
+ .write_trailer = framemd5_write_trailer, |
|
107 | 115 |
.flags = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT, |
108 | 116 |
}; |
109 | 117 |
#endif |
... | ... |
@@ -27,37 +27,41 @@ |
27 | 27 |
#include "avio.h" |
28 | 28 |
#include "url.h" |
29 | 29 |
|
30 |
-#define PRIV_SIZE 128 |
|
30 |
+struct MD5Context { |
|
31 |
+ struct AVMD5 *md5; |
|
32 |
+}; |
|
31 | 33 |
|
32 | 34 |
static int md5_open(URLContext *h, const char *filename, int flags) |
33 | 35 |
{ |
34 |
- if (PRIV_SIZE < av_md5_size) { |
|
35 |
- av_log(NULL, AV_LOG_ERROR, "Insuffient size for MD5 context\n"); |
|
36 |
- return -1; |
|
37 |
- } |
|
36 |
+ struct MD5Context *c = h->priv_data; |
|
38 | 37 |
|
39 | 38 |
if (!(flags & AVIO_FLAG_WRITE)) |
40 | 39 |
return AVERROR(EINVAL); |
41 | 40 |
|
42 |
- av_md5_init(h->priv_data); |
|
41 |
+ c->md5 = av_md5_alloc(); |
|
42 |
+ if (!c->md5) |
|
43 |
+ return AVERROR(ENOMEM); |
|
44 |
+ av_md5_init(c->md5); |
|
43 | 45 |
|
44 | 46 |
return 0; |
45 | 47 |
} |
46 | 48 |
|
47 | 49 |
static int md5_write(URLContext *h, const unsigned char *buf, int size) |
48 | 50 |
{ |
49 |
- av_md5_update(h->priv_data, buf, size); |
|
51 |
+ struct MD5Context *c = h->priv_data; |
|
52 |
+ av_md5_update(c->md5, buf, size); |
|
50 | 53 |
return size; |
51 | 54 |
} |
52 | 55 |
|
53 | 56 |
static int md5_close(URLContext *h) |
54 | 57 |
{ |
58 |
+ struct MD5Context *c = h->priv_data; |
|
55 | 59 |
const char *filename = h->filename; |
56 | 60 |
uint8_t md5[16], buf[64]; |
57 | 61 |
URLContext *out; |
58 | 62 |
int i, err = 0; |
59 | 63 |
|
60 |
- av_md5_final(h->priv_data, md5); |
|
64 |
+ av_md5_final(c->md5, md5); |
|
61 | 65 |
for (i = 0; i < sizeof(md5); i++) |
62 | 66 |
snprintf(buf + i*2, 3, "%02x", md5[i]); |
63 | 67 |
buf[i*2] = '\n'; |
... | ... |
@@ -76,6 +80,8 @@ static int md5_close(URLContext *h) |
76 | 76 |
err = AVERROR(errno); |
77 | 77 |
} |
78 | 78 |
|
79 |
+ av_freep(&c->md5); |
|
80 |
+ |
|
79 | 81 |
return err; |
80 | 82 |
} |
81 | 83 |
|
... | ... |
@@ -85,5 +91,5 @@ URLProtocol ff_md5_protocol = { |
85 | 85 |
.url_open = md5_open, |
86 | 86 |
.url_write = md5_write, |
87 | 87 |
.url_close = md5_close, |
88 |
- .priv_data_size = PRIV_SIZE, |
|
88 |
+ .priv_data_size = sizeof(struct MD5Context), |
|
89 | 89 |
}; |
... | ... |
@@ -21,6 +21,8 @@ |
21 | 21 |
|
22 | 22 |
#include <stdio.h> |
23 | 23 |
#include <string.h> |
24 |
+ |
|
25 |
+#include "common.h" |
|
24 | 26 |
#include "pixfmt.h" |
25 | 27 |
#include "pixdesc.h" |
26 | 28 |
|
... | ... |
@@ -122,6 +124,9 @@ void av_write_image_line(const uint16_t *src, |
122 | 122 |
} |
123 | 123 |
} |
124 | 124 |
|
125 |
+#if !FF_API_PIX_FMT_DESC |
|
126 |
+static |
|
127 |
+#endif |
|
125 | 128 |
const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { |
126 | 129 |
[AV_PIX_FMT_YUV420P] = { |
127 | 130 |
.name = "yuv420p", |
... | ... |
@@ -1485,3 +1490,28 @@ char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt |
1485 | 1485 |
|
1486 | 1486 |
return buf; |
1487 | 1487 |
} |
1488 |
+ |
|
1489 |
+const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt) |
|
1490 |
+{ |
|
1491 |
+ if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB) |
|
1492 |
+ return NULL; |
|
1493 |
+ return &av_pix_fmt_descriptors[pix_fmt]; |
|
1494 |
+} |
|
1495 |
+ |
|
1496 |
+const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev) |
|
1497 |
+{ |
|
1498 |
+ if (!prev) |
|
1499 |
+ return &av_pix_fmt_descriptors[0]; |
|
1500 |
+ if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) |
|
1501 |
+ return prev + 1; |
|
1502 |
+ return NULL; |
|
1503 |
+} |
|
1504 |
+ |
|
1505 |
+enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc) |
|
1506 |
+{ |
|
1507 |
+ if (desc < av_pix_fmt_descriptors || |
|
1508 |
+ desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors)) |
|
1509 |
+ return AV_PIX_FMT_NONE; |
|
1510 |
+ |
|
1511 |
+ return desc - av_pix_fmt_descriptors; |
|
1512 |
+} |
... | ... |
@@ -99,10 +99,12 @@ typedef struct AVPixFmtDescriptor{ |
99 | 99 |
*/ |
100 | 100 |
#define PIX_FMT_PSEUDOPAL 64 |
101 | 101 |
|
102 |
+#if FF_API_PIX_FMT_DESC |
|
102 | 103 |
/** |
103 | 104 |
* The array of all the pixel format descriptors. |
104 | 105 |
*/ |
105 | 106 |
extern const AVPixFmtDescriptor av_pix_fmt_descriptors[]; |
107 |
+#endif |
|
106 | 108 |
|
107 | 109 |
/** |
108 | 110 |
* 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 |
183 | 183 |
*/ |
184 | 184 |
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc); |
185 | 185 |
|
186 |
+/** |
|
187 |
+ * @return a pixel format descriptor for provided pixel format or NULL if |
|
188 |
+ * this pixel format is unknown. |
|
189 |
+ */ |
|
190 |
+const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt); |
|
191 |
+ |
|
192 |
+/** |
|
193 |
+ * Iterate over all pixel format descriptors known to libavutil. |
|
194 |
+ * |
|
195 |
+ * @param prev previous descriptor. NULL to get the first descriptor. |
|
196 |
+ * |
|
197 |
+ * @return next descriptor or NULL after the last descriptor |
|
198 |
+ */ |
|
199 |
+const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev); |
|
200 |
+ |
|
201 |
+/** |
|
202 |
+ * @return an AVPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc |
|
203 |
+ * is not a valid pointer to a pixel format descriptor. |
|
204 |
+ */ |
|
205 |
+enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc); |
|
206 |
+ |
|
186 | 207 |
#endif /* AVUTIL_PIXDESC_H */ |
... | ... |
@@ -39,7 +39,7 @@ |
39 | 39 |
*/ |
40 | 40 |
|
41 | 41 |
#define LIBAVUTIL_VERSION_MAJOR 51 |
42 |
-#define LIBAVUTIL_VERSION_MINOR 75 |
|
42 |
+#define LIBAVUTIL_VERSION_MINOR 76 |
|
43 | 43 |
#define LIBAVUTIL_VERSION_MICRO 100 |
44 | 44 |
|
45 | 45 |
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
... | ... |
@@ -87,6 +87,9 @@ |
87 | 87 |
#ifndef FF_API_CONTEXT_SIZE |
88 | 88 |
#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52) |
89 | 89 |
#endif |
90 |
+#ifndef FF_API_PIX_FMT_DESC |
|
91 |
+#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 52) |
|
92 |
+#endif |
|
90 | 93 |
|
91 | 94 |
/** |
92 | 95 |
* @} |
... | ... |
@@ -82,9 +82,10 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph) |
82 | 82 |
link->srcpad->name, link->dstpad->name); |
83 | 83 |
|
84 | 84 |
if (link->type == AVMEDIA_TYPE_VIDEO) { |
85 |
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); |
|
85 | 86 |
fprintf(outfile, |
86 | 87 |
"fmt:%s w:%d h:%d tb:%d/%d", |
87 |
- av_pix_fmt_descriptors[link->format].name, |
|
88 |
+ desc->name, |
|
88 | 89 |
link->w, link->h, |
89 | 90 |
link->time_base.num, link->time_base.den); |
90 | 91 |
} else if (link->type == AVMEDIA_TYPE_AUDIO) { |