Skip to content

Commit

Permalink
Deprecate av_parse_video_frame_size() and av_parse_video_frame_rate()
Browse files Browse the repository at this point in the history
in favor of the newly added corresponding functions
av_parse_video_size() and av_parse_video_rate() defined in
libavcore/parseutils.h.

This change also adds a linking-time dependency of libavcodec and of
libavfilter on libavcore.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@24518 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
  • Loading branch information
stefano committed Jul 26, 2010
1 parent 7e9fb12 commit 96afd94
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 149 deletions.
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3207,11 +3207,11 @@ EOF

pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
pkgconfig_generate libavcore "FFmpeg multimedia shared core utilities library" "$LIBAVCORE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
enabled avfilter &&
pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
enabled postproc &&
pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
5 changes: 3 additions & 2 deletions ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "libswscale/swscale.h"
#include "libavcodec/opt.h"
#include "libavcodec/audioconvert.h"
#include "libavcore/parseutils.h"
#include "libavutil/colorspace.h"
#include "libavutil/fifo.h"
#include "libavutil/pixdesc.h"
Expand Down Expand Up @@ -2738,7 +2739,7 @@ static int opt_verbose(const char *opt, const char *arg)

static int opt_frame_rate(const char *opt, const char *arg)
{
if (av_parse_video_frame_rate(&frame_rate, arg) < 0) {
if (av_parse_video_rate(&frame_rate, arg) < 0) {
fprintf(stderr, "Incorrect value for %s: %s\n", opt, arg);
ffmpeg_exit(1);
}
Expand Down Expand Up @@ -2819,7 +2820,7 @@ static void opt_frame_crop_right(const char *arg)

static void opt_frame_size(const char *arg)
{
if (av_parse_video_frame_size(&frame_width, &frame_height, arg) < 0) {
if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
fprintf(stderr, "Incorrect frame size\n");
ffmpeg_exit(1);
}
Expand Down
3 changes: 2 additions & 1 deletion ffplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "libavutil/avstring.h"
#include "libavutil/colorspace.h"
#include "libavutil/pixdesc.h"
#include "libavcore/parseutils.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
Expand Down Expand Up @@ -2949,7 +2950,7 @@ static void event_loop(void)

static void opt_frame_size(const char *arg)
{
if (av_parse_video_frame_size(&frame_width, &frame_height, arg) < 0) {
if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
fprintf(stderr, "Incorrect frame size\n");
exit(1);
}
Expand Down
5 changes: 3 additions & 2 deletions ffserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "libavutil/avstring.h"
#include "libavutil/lfg.h"
#include "libavutil/random_seed.h"
#include "libavcore/parseutils.h"
#include "libavcodec/opt.h"
#include <stdarg.h>
#include <unistd.h>
Expand Down Expand Up @@ -4410,7 +4411,7 @@ static int parse_ffconfig(const char *filename)
} else if (!strcasecmp(cmd, "VideoSize")) {
get_arg(arg, sizeof(arg), &p);
if (stream) {
av_parse_video_frame_size(&video_enc.width, &video_enc.height, arg);
av_parse_video_size(&video_enc.width, &video_enc.height, arg);
if ((video_enc.width % 16) != 0 ||
(video_enc.height % 16) != 0) {
ERROR("Image size must be a multiple of 16\n");
Expand All @@ -4420,7 +4421,7 @@ static int parse_ffconfig(const char *filename)
get_arg(arg, sizeof(arg), &p);
if (stream) {
AVRational frame_rate;
if (av_parse_video_frame_rate(&frame_rate, arg) < 0) {
if (av_parse_video_rate(&frame_rate, arg) < 0) {
ERROR("Incorrect frame rate: %s\n", arg);
} else {
video_enc.time_base.num = frame_rate.den;
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(SUBDIR)../config.mak

NAME = avcodec
FFLIBS = avutil
FFLIBS = avutil avcore

HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h

Expand Down
22 changes: 7 additions & 15 deletions libavcodec/avcodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define LIBAVCODEC_VERSION_MAJOR 52
#define LIBAVCODEC_VERSION_MINOR 84
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_MICRO 1

#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
Expand Down Expand Up @@ -3964,29 +3964,21 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
*/
unsigned int av_xiphlacing(unsigned char *s, unsigned int v);

#if LIBAVCODEC_VERSION_MAJOR < 53
/**
* Parse str and put in width_ptr and height_ptr the detected values.
*
* @return 0 in case of a successful parsing, a negative value otherwise
* @param[in] str the string to parse: it has to be a string in the format
* width x height or a valid video frame size abbreviation.
* @param[in,out] width_ptr pointer to the variable which will contain the detected
* frame width value
* @param[in,out] height_ptr pointer to the variable which will contain the detected
* frame height value
* @deprecated Deprecated in favor of av_parse_video_size().
*/
int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);

/**
* Parse str and store the detected values in *frame_rate.
*
* @return 0 in case of a successful parsing, a negative value otherwise
* @param[in] str the string to parse: it has to be a string in the format
* frame_rate_num / frame_rate_den, a float number or a valid video rate abbreviation
* @param[in,out] frame_rate pointer to the AVRational which will contain the detected
* frame rate
* @deprecated Deprecated in favor of av_parse_video_rate().
*/
int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
#endif

/**
* Logs a generic warning message about a missing feature. This function is
Expand Down
123 changes: 5 additions & 118 deletions libavcodec/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1092,132 +1092,19 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
return n;
}

typedef struct {
const char *abbr;
int width, height;
} VideoFrameSizeAbbr;

typedef struct {
const char *abbr;
int rate_num, rate_den;
} VideoFrameRateAbbr;

static const VideoFrameSizeAbbr video_frame_size_abbrs[] = {
{ "ntsc", 720, 480 },
{ "pal", 720, 576 },
{ "qntsc", 352, 240 }, /* VCD compliant NTSC */
{ "qpal", 352, 288 }, /* VCD compliant PAL */
{ "sntsc", 640, 480 }, /* square pixel NTSC */
{ "spal", 768, 576 }, /* square pixel PAL */
{ "film", 352, 240 },
{ "ntsc-film", 352, 240 },
{ "sqcif", 128, 96 },
{ "qcif", 176, 144 },
{ "cif", 352, 288 },
{ "4cif", 704, 576 },
{ "16cif", 1408,1152 },
{ "qqvga", 160, 120 },
{ "qvga", 320, 240 },
{ "vga", 640, 480 },
{ "svga", 800, 600 },
{ "xga", 1024, 768 },
{ "uxga", 1600,1200 },
{ "qxga", 2048,1536 },
{ "sxga", 1280,1024 },
{ "qsxga", 2560,2048 },
{ "hsxga", 5120,4096 },
{ "wvga", 852, 480 },
{ "wxga", 1366, 768 },
{ "wsxga", 1600,1024 },
{ "wuxga", 1920,1200 },
{ "woxga", 2560,1600 },
{ "wqsxga", 3200,2048 },
{ "wquxga", 3840,2400 },
{ "whsxga", 6400,4096 },
{ "whuxga", 7680,4800 },
{ "cga", 320, 200 },
{ "ega", 640, 350 },
{ "hd480", 852, 480 },
{ "hd720", 1280, 720 },
{ "hd1080", 1920,1080 },
};

static const VideoFrameRateAbbr video_frame_rate_abbrs[]= {
{ "ntsc", 30000, 1001 },
{ "pal", 25, 1 },
{ "qntsc", 30000, 1001 }, /* VCD compliant NTSC */
{ "qpal", 25, 1 }, /* VCD compliant PAL */
{ "sntsc", 30000, 1001 }, /* square pixel NTSC */
{ "spal", 25, 1 }, /* square pixel PAL */
{ "film", 24, 1 },
{ "ntsc-film", 24000, 1001 },
};
#if LIBAVCODEC_VERSION_MAJOR < 53
#include "libavcore/parseutils.h"

int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str)
{
int i;
int n = FF_ARRAY_ELEMS(video_frame_size_abbrs);
char *p;
int frame_width = 0, frame_height = 0;

for(i=0;i<n;i++) {
if (!strcmp(video_frame_size_abbrs[i].abbr, str)) {
frame_width = video_frame_size_abbrs[i].width;
frame_height = video_frame_size_abbrs[i].height;
break;
}
}
if (i == n) {
p = str;
frame_width = strtol(p, &p, 10);
if (*p)
p++;
frame_height = strtol(p, &p, 10);
}
if (frame_width <= 0 || frame_height <= 0)
return -1;
*width_ptr = frame_width;
*height_ptr = frame_height;
return 0;
return av_parse_video_size(width_ptr, height_ptr, str);
}

int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg)
{
int i;
int n = FF_ARRAY_ELEMS(video_frame_rate_abbrs);
char* cp;

/* First, we check our abbreviation table */
for (i = 0; i < n; ++i)
if (!strcmp(video_frame_rate_abbrs[i].abbr, arg)) {
frame_rate->num = video_frame_rate_abbrs[i].rate_num;
frame_rate->den = video_frame_rate_abbrs[i].rate_den;
return 0;
}

/* Then, we try to parse it as fraction */
cp = strchr(arg, '/');
if (!cp)
cp = strchr(arg, ':');
if (cp) {
char* cpp;
frame_rate->num = strtol(arg, &cpp, 10);
if (cpp != arg || cpp == cp)
frame_rate->den = strtol(cp+1, &cpp, 10);
else
frame_rate->num = 0;
}
else {
/* Finally we give up and parse it as double */
AVRational time_base = av_d2q(strtod(arg, 0), 1001000);
frame_rate->den = time_base.den;
frame_rate->num = time_base.num;
}
if (!frame_rate->num || !frame_rate->den)
return -1;
else
return 0;
return av_parse_video_rate(frame_rate, arg);
}
#endif

int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){
int i;
Expand Down
4 changes: 3 additions & 1 deletion libavcore/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ include $(SUBDIR)../config.mak
NAME = avcore

HEADERS = avcore.h \
parseutils.h \

OBJS = utils.o \
OBJS = parseutils.o \
utils.o \

include $(SUBDIR)../subdir.mak
2 changes: 1 addition & 1 deletion libavcore/avcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <libavutil/avutil.h>

#define LIBAVCORE_VERSION_MAJOR 0
#define LIBAVCORE_VERSION_MINOR 0
#define LIBAVCORE_VERSION_MINOR 1
#define LIBAVCORE_VERSION_MICRO 0

#define LIBAVCORE_VERSION_INT AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
Expand Down
Loading

0 comments on commit 96afd94

Please sign in to comment.