Remove the dependency of pixfmt.h in ffms.h
Added the alternative FFMS_GetPixFmt() for getting the different pixel format values

Originally committed to SVN as r2845.
This commit is contained in:
Fredrik Mellbin 2009-04-24 19:56:19 +00:00
parent aaad6b4ad6
commit 6fae2955fd
6 changed files with 44 additions and 34 deletions

View File

@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <libavutil/pixfmt.h>
#include "ffavisynth.h"
#include "utils.h"
@ -74,9 +75,9 @@ AvisynthVideoSource::~AvisynthVideoSource() {
FFMS_DestroyVideoSource(VS);
}
void AvisynthVideoSource::InitOutputFormat(PixelFormat CurrentFormat, IScriptEnvironment *Env) {
void AvisynthVideoSource::InitOutputFormat(enum PixelFormat CurrentFormat, IScriptEnvironment *Env) {
int Loss;
PixelFormat BestFormat = avcodec_find_best_pix_fmt((1 << PIX_FMT_YUVJ420P) | (1 << PIX_FMT_YUV420P) | (1 << PIX_FMT_YUYV422) | (1 << PIX_FMT_RGB32) | (1 << PIX_FMT_BGR24), CurrentFormat, 1 /* Required to prevent pointless RGB32 => RGB24 conversion */, &Loss);
enum PixelFormat BestFormat = avcodec_find_best_pix_fmt((1 << PIX_FMT_YUVJ420P) | (1 << PIX_FMT_YUV420P) | (1 << PIX_FMT_YUYV422) | (1 << PIX_FMT_RGB32) | (1 << PIX_FMT_BGR24), CurrentFormat, 1 /* Required to prevent pointless RGB32 => RGB24 conversion */, &Loss);
switch (BestFormat) {
case PIX_FMT_YUVJ420P: // stupid yv12 distinctions, also inexplicably completely undeniably incompatible with all other supported output formats

View File

@ -41,7 +41,7 @@ private:
int FPSNum;
int FPSDen;
void InitOutputFormat(PixelFormat CurrentFormat, IScriptEnvironment *Env);
void InitOutputFormat(enum PixelFormat CurrentFormat, IScriptEnvironment *Env);
PVideoFrame OutputFrame(const AVFrameLite *SrcPicture, IScriptEnvironment *Env);
public:
AvisynthVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, int FPSNum, int FPSDen, const char *PP, int Threads, int SeekMode, IScriptEnvironment* Env, char *ErrorMsg, unsigned MsgSize);

View File

@ -18,6 +18,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern "C" {
#include <libavcodec/avcodec.h>
}
#include "ffms.h"
#include "ffvideosource.h"
#include "ffaudiosource.h"
@ -205,3 +209,6 @@ FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, c
return WriteIndex(IndexFile, TrackIndices, ErrorMsg, MsgSize);
}
FFMS_API(enum PixelFormat) FFMS_GetPixFmt(const char *Name) {
return avcodec_get_pix_fmt(Name);
}

View File

@ -22,7 +22,6 @@
#define FFMS_H
#include <stdint.h>
#include <libavutil/pixfmt.h>
#ifdef __cplusplus
# define EXTERN_C extern "C"
@ -49,6 +48,8 @@ class FrameInfoVector;
typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private);
enum PixelFormat;
enum FFMS_SeekMode {
FFMS_SEEK_LINEAR_NO_RW = -1,
FFMS_SEEK_LINEAR = 0,
@ -98,7 +99,7 @@ struct VideoProperties {
int FPSDenominator;
int FPSNumerator;
int NumFrames;
PixelFormat VPixelFormat;
enum PixelFormat VPixelFormat;
int SARNum;
int SARDen;
int CropTop;
@ -147,5 +148,5 @@ FFMS_API(int) FFMS_WriteTimecodes(FrameInfoVector *FIV, const char *TimecodeFile
FFMS_API(FrameIndex *) FFMS_MakeIndex(const char *SourceFile, int IndexMask, int DumpMask, const char *AudioFile, bool IgnoreDecodeErrors, IndexCallback IP, void *Private, char *ErrorMsg, unsigned MsgSize);
FFMS_API(FrameIndex *) FFMS_ReadIndex(const char *IndexFile, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
FFMS_API(PixelFormat) FFMS_GetPixFmt(const char *Name);
#endif

View File

@ -234,6 +234,7 @@ Note that --enable-w32threads is required for multithreaded decoding to work.
<h2>Changes</h2>
<ul>
<li>2.00 beta 7<ul>
<li>Using ffms2 as a library no longer requires an installed pixfmt.h from libavutil, it is however still required to compile ffms2 and the avisynth plugin part</li>
<li>Fix a crash bug at the end of files with b-frames in beta 6 caused by uninitialized null packets</li>
<li>Includes TheFluff's wrapper function for 1.21 style syntax</li>
<li>Added a simple regression test application to the source</li>

View File

@ -28,7 +28,7 @@ extern "C" {
using namespace std;
//#define VERBOSE
#define VERBOSE
static int FFMS_CC UpdateProgress(int State, int64_t Current, int64_t Total, void *Private) {
@ -59,7 +59,11 @@ int main(int argc, char *argv[]) {
#ifndef VERBOSE
FFMS_NoLog();
#endif
enum PixelFormat FMT_YV12A = FFMS_GetPixFmt("PIX_FMT_YUV420P)");
enum PixelFormat FMT_YV12B = FFMS_GetPixFmt("PIX_FMT_YUVJ420P");
enum PixelFormat FMT_YUY2 = FFMS_GetPixFmt("PIX_FMT_YUV422P");
av_md5_init(ctx);
FrameIndex *FI = FFMS_MakeIndex(argv[1], -1, 0, NULL, false, UpdateProgress, argv[1], ErrorMsg, sizeof(ErrorMsg));
if (!FI) {
@ -103,32 +107,28 @@ int main(int argc, char *argv[]) {
Data[1] = AVF->Data[1];
Data[2] = AVF->Data[2];
switch (VP->VPixelFormat) {
case PIX_FMT_YUV420P:
case PIX_FMT_YUVJ420P:
for (int j = 0; j < VP->Height / 2; j++) {
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[1], VP->Width / 2);
Data[1] += AVF->Linesize[1];
av_md5_update(ctx, Data[2], VP->Width / 2);
Data[2] += AVF->Linesize[2];
}
break;
case PIX_FMT_YUV422P:
for (int j = 0; j < VP->Height / 2; j++) {
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[1], VP->Width / 2);
Data[1] += AVF->Linesize[1];
av_md5_update(ctx, Data[2], VP->Width / 2);
Data[2] += AVF->Linesize[2];
}
break;
if (VP->VPixelFormat == FMT_YV12A || VP->VPixelFormat == FMT_YV12B) {
for (int j = 0; j < VP->Height / 2; j++) {
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[1], VP->Width / 2);
Data[1] += AVF->Linesize[1];
av_md5_update(ctx, Data[2], VP->Width / 2);
Data[2] += AVF->Linesize[2];
}
} else if (VP->VPixelFormat == FMT_YUY2) {
for (int j = 0; j < VP->Height / 2; j++) {
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[0], VP->Width);
Data[0] += AVF->Linesize[0];
av_md5_update(ctx, Data[1], VP->Width / 2);
Data[1] += AVF->Linesize[1];
av_md5_update(ctx, Data[2], VP->Width / 2);
Data[2] += AVF->Linesize[2];
}
}
}