Newer
Older
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_U32BE:
case CODEC_ID_PCM_U32LE:
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_F64BE:
case CODEC_ID_PCM_F64LE:
return 64;
default:
return 0;
}
}
int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) {
switch (sample_fmt) {
case SAMPLE_FMT_U8:
return 8;
case SAMPLE_FMT_S16:
return 16;
case SAMPLE_FMT_S32:
case SAMPLE_FMT_FLT:
return 32;
default:
return 0;
}
}
int avcodec_thread_init(AVCodecContext *s, int thread_count){
s->thread_count = thread_count;
return -1;
}
#endif
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
{
unsigned int n = 0;
while(v >= 0xff) {
*s++ = 0xff;
v -= 0xff;
n++;
}
*s = v;
n++;
return n;
}
/* Wrapper to work around the lack of mkstemp() on mingw/cygin.
* Also, tries to create file in /tmp first, if possible.
* *prefix can be a character constant; *filename will be allocated internally.
* Returns file descriptor of opened file (or -1 on error)
* and opened file name in **filename. */
int av_tempfile(char *prefix, char **filename) {
int fd=-1;
*filename = tempnam(".", prefix);
#else
size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
#endif
/* -----common section-----*/
if (*filename == NULL) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
return -1;
}
fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
#else
snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
fd = mkstemp(*filename);
if (fd < 0) {
snprintf(*filename, len, "./%sXXXXXX", prefix);
fd = mkstemp(*filename);
}
#endif
/* -----common section-----*/
if (fd < 0) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
return -1;
}
return fd; /* success */
}
Stefano Sabatini
committed
typedef struct {
const char *abbr;
Stefano Sabatini
committed
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 },
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
{ "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 },
Stefano Sabatini
committed
};
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;
Stefano Sabatini
committed
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;
Stefano Sabatini
committed
break;
}
}
if (i == n) {
p = str;
frame_width = strtol(p, &p, 10);
Stefano Sabatini
committed
if (*p)
p++;
frame_height = strtol(p, &p, 10);
Stefano Sabatini
committed
}
if (frame_width <= 0 || frame_height <= 0)
return -1;
*width_ptr = frame_width;
*height_ptr = frame_height;
return 0;
}
int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg)
{
int i;
int n = FF_ARRAY_ELEMS(video_frame_rate_abbrs);
Stefano Sabatini
committed
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;
Stefano Sabatini
committed
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);
Stefano Sabatini
committed
frame_rate->den = time_base.den;
frame_rate->num = time_base.num;
}
if (!frame_rate->num || !frame_rate->den)
return -1;
else
return 0;
}
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
{
av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg "
"version to the newest one from SVN. If the problem still "
"occurs, it means that your file has a feature which has not "
"been implemented.", feature);
if(want_sample)
av_log_ask_for_sample(avc, NULL);
else
av_log(avc, AV_LOG_WARNING, "\n");
}
void av_log_ask_for_sample(void *avc, const char *msg)
{
if (msg)
av_log(avc, AV_LOG_WARNING, "%s ", msg);
av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
"of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ "
"and contact the ffmpeg-devel mailing list.\n");
}
static AVHWAccel *first_hwaccel = NULL;
void av_register_hwaccel(AVHWAccel *hwaccel)
{
AVHWAccel **p = &first_hwaccel;
while (*p)
p = &(*p)->next;
*p = hwaccel;
hwaccel->next = NULL;
}
AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
{
return hwaccel ? hwaccel->next : first_hwaccel;
}
AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt)
{
AVHWAccel *hwaccel=NULL;
while((hwaccel= av_hwaccel_next(hwaccel))){
if ( hwaccel->id == codec_id
&& hwaccel->pix_fmt == pix_fmt)
return hwaccel;
}
return NULL;
}
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
{
if (ff_lockmgr_cb) {
if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY))
return -1;
}
ff_lockmgr_cb = cb;
if (ff_lockmgr_cb) {
if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE))
return -1;
}
return 0;
}