History

tools: do not use av_pix_fmt_descriptors directly.

Anton Khirnov committed 14 years ago

Commit b7f10101 parent d2fcb353 files · +16 −10Browse files

Unified · Split

3 files
  1. avprobe.c +3 −3
  2. cmdutils.c +11 −5
  3. tools/graph2dot.c +2 −2
avprobe.c+3−3
@@ -584,6 +584,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) · 583 unmodified lines
584584 const char *profile;
585585 char val_str[128];
586586 AVRational display_aspect_ratio;
587+ const AVPixFmtDescriptor *desc;
587588
588589 probe_object_header("stream");
589590
@@ -629,9 +630,8 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) · 39 unmodified lines
629630 rational_string(val_str, sizeof(val_str), ":",
630631 &display_aspect_ratio));
631632 }
632− probe_str("pix_fmt",
633− dec_ctx->pix_fmt != AV_PIX_FMT_NONE ?
634− av_pix_fmt_descriptors[dec_ctx->pix_fmt].name : "unknown");
633+ desc = av_pix_fmt_desc_get(dec_ctx->pix_fmt);
634+ probe_str("pix_fmt", desc ? desc->name : "unknown");
635635 probe_int("level", dec_ctx->level);
636636 break;
637637
cmdutils.c+11−5
@@ -866,7 +866,7 @@ int show_filters(void *optctx, const char *opt, const char *arg) · 865 unmodified lines
866866
867867 int show_pix_fmts(void *optctx, const char *opt, const char *arg)
868868 {
869− enum AVPixelFormat pix_fmt;
869+ const AVPixFmtDescriptor *pix_desc = NULL;
870870
871871 printf("Pixel formats:\n"
872872 "I.... = Supported Input format for conversion\n"
@@ -882,8 +882,8 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg) · 9 unmodified lines
882882 # define sws_isSupportedOutput(x) 0
883883 #endif
884884
885− for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++) {
886− const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt];
885+ while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
886+ enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
887887 printf("%c%c%c%c%c %-16s %d %2d\n",
888888 sws_isSupportedInput (pix_fmt) ? 'I' : '.',
889889 sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
@@ -1282,13 +1282,19 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) · 392 unmodified lines
12821282
12831283 static int alloc_buffer(FrameBuffer **pool, AVCodecContext *s, FrameBuffer **pbuf)
12841284 {
1285− FrameBuffer *buf = av_mallocz(sizeof(*buf));
1285+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
1286+ FrameBuffer *buf;
12861287 int i, ret;
1287− const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
1288+ int pixel_size;
12881289 int h_chroma_shift, v_chroma_shift;
12891290 int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1
12901291 int w = s->width, h = s->height;
12911292
1293+ if (!desc)
1294+ return AVERROR(EINVAL);
1295+ pixel_size = desc->comp[0].step_minus1 + 1;
1296+
1297+ buf = av_mallocz(sizeof(*buf));
12921298 if (!buf)
12931299 return AVERROR(ENOMEM);
12941300
tools/graph2dot.c+2−2
@@ -80,10 +80,10 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph) · 79 unmodified lines
8080 fprintf(outfile, "\"%s\" -> \"%s\"",
8181 filter_ctx_label, dst_filter_ctx_label);
8282 if (link->type == AVMEDIA_TYPE_VIDEO) {
83+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
8384 fprintf(outfile,
8485 " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
85− av_pix_fmt_descriptors[link->format].name,
86− link->w, link->h, link->time_base.num,
86+ desc->name, link->w, link->h, link->time_base.num,
8787 link->time_base.den);
8888 } else if (link->type == AVMEDIA_TYPE_AUDIO) {
8989 char buf[255];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t