* 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>tags/n1.1
| @@ -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); | |||
| @@ -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) | |||
| ;; | |||
| *) | |||
| @@ -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. | |||
| @@ -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 | |||
| @@ -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), | |||
| }; | |||
| @@ -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; | |||
| } | |||
| @@ -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 */ | |||
| @@ -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 | |||
| /** | |||
| * @} | |||
| @@ -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) { | |||