aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpdemux
diff options
context:
space:
mode:
authorGravatar ranma <ranma@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-03-22 01:42:43 +0000
committerGravatar ranma <ranma@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-03-22 01:42:43 +0000
commit10c153004d0d4fec82ea13240001a48366c50cf7 (patch)
treed4dbef5be86230732e155b369a0359f6d344b682 /libmpdemux
parent12542092df13506fd30a798ab2b059c8671936fd (diff)
Better vprp aspect fix
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12054 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/aviheader.c4
-rw-r--r--libmpdemux/muxer_avi.c24
2 files changed, 18 insertions, 10 deletions
diff --git a/libmpdemux/aviheader.c b/libmpdemux/aviheader.c
index 7727d5285c..a52d883c2f 100644
--- a/libmpdemux/aviheader.c
+++ b/libmpdemux/aviheader.c
@@ -28,6 +28,8 @@ extern void print_index(AVIINDEXENTRY *idx,int idx_size);
extern void print_avistdindex_chunk(avistdindex_chunk *h);
extern void print_avisuperindex_chunk(avisuperindex_chunk *h);
+int avi_use_vprp_aspect = 0;
+
static int odml_get_vstream_id(int id, unsigned char res[])
{
unsigned char *p = (unsigned char *)&id;
@@ -343,7 +345,7 @@ while(1){
for (i=0; i<vprp->nbFieldPerFrame; i++) {
le2me_VIDEO_FIELD_DESC(&vprp->FieldInfo[i]);
}
- if (sh_video) {
+ if (avi_use_vprp_aspect && sh_video) {
sh_video->aspect = GET_AVI_ASPECT(vprp->dwFrameAspectRatio);
}
if(verbose>=1) print_vprp(vprp);
diff --git a/libmpdemux/muxer_avi.c b/libmpdemux/muxer_avi.c
index f51d35b01f..abe4d5d9f7 100644
--- a/libmpdemux/muxer_avi.c
+++ b/libmpdemux/muxer_avi.c
@@ -34,7 +34,7 @@ extern char *info_comment;
#define ODML_NOTKEYFRAME 0x80000000U
#define MOVIALIGN 0x00001000
-float avi_prp_aspect = -1.0;
+extern int avi_use_vprp_aspect;
struct avi_odmlidx_entry {
uint64_t ofs;
@@ -227,6 +227,9 @@ static void write_avi_list(FILE *f,unsigned int id,int len){
static unsigned int avi_aspect(float aspect)
{
+ if (aspect <= 0.0) {
+ aspect = 4.0/3.0;
+ }
if (aspect >= 3.99/3.0 &&
aspect <= 4.01/3.0) return MAKE_AVI_ASPECT(4,3);
if (aspect >= 15.99/9.0 &&
@@ -313,7 +316,7 @@ static void avifile_write_header(muxer_t *muxer){
switch(muxer->streams[i]->type){
case MUXER_TYPE_VIDEO:
hdrsize+=muxer->streams[i]->bih->biSize+8; // strf
- if (avi_prp_aspect > 0) {
+ if (avi_use_vprp_aspect) {
hdrsize+=8+4*(9+8*1); // vprp
}
break;
@@ -348,13 +351,14 @@ static void avifile_write_header(muxer_t *muxer){
s->h.fccHandler = s->bih->biCompression;
s->h.rcFrame.right = s->bih->biWidth;
s->h.rcFrame.bottom = s->bih->biHeight;
- if (avi_prp_aspect > 0) {
+ if (avi_use_vprp_aspect) {
+ sh_video_t *sh_video = s->source;
// fill out vprp info
memset(&vprp, 0, sizeof(vprp));
vprp.dwVerticalRefreshRate = (s->h.dwRate+s->h.dwScale-1)/s->h.dwScale;
vprp.dwHTotalInT = muxer->avih.dwWidth;
vprp.dwVTotalInLines = muxer->avih.dwHeight;
- vprp.dwFrameAspectRatio = avi_aspect(avi_prp_aspect);
+ vprp.dwFrameAspectRatio = avi_aspect(sh_video->aspect);
vprp.dwFrameWidthInPixels = muxer->avih.dwWidth;
vprp.dwFrameHeightInLines = muxer->avih.dwHeight;
vprp.nbFieldPerFrame = 1;
@@ -382,15 +386,17 @@ static void avifile_write_header(muxer_t *muxer){
int biSize=s->bih->biSize;
le2me_BITMAPINFOHEADER(s->bih);
write_avi_chunk(f,ckidSTREAMFORMAT,biSize,s->bih); /* BITMAPINFOHEADER */
- if (avi_prp_aspect > 0) {
- le2me_BITMAPINFOHEADER(s->bih);
+ le2me_BITMAPINFOHEADER(s->bih);
+
+ if (avi_use_vprp_aspect) {
+ int fields = vprp.nbFieldPerFrame;
le2me_VideoPropHeader(&vprp);
le2me_VIDEO_FIELD_DESC(&vprp.FieldInfo[0]);
le2me_VIDEO_FIELD_DESC(&vprp.FieldInfo[1]);
write_avi_chunk(f,mmioFOURCC('v','p','r','p'),
- sizeof(VideoPropHeader) -
- sizeof(VIDEO_FIELD_DESC)*(2-vprp.nbFieldPerFrame),
- &vprp); /* Video Properties Header */
+ sizeof(VideoPropHeader) -
+ sizeof(VIDEO_FIELD_DESC)*(2-fields),
+ &vprp); /* Video Properties Header */
}
}
break;