Mercurial > mplayer.hg
changeset 12051:78884d076dd4
explicit option for AVI PRP header
author | henry |
---|---|
date | Sun, 21 Mar 2004 21:32:54 +0000 |
parents | 96336c83b249 |
children | 69cf59bb739d |
files | DOCS/man/en/mplayer.1 cfg-mencoder.h libmpdemux/muxer_avi.c |
diffstat | 3 files changed, 62 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Sun Mar 21 14:24:45 2004 +0000 +++ b/DOCS/man/en/mplayer.1 Sun Mar 21 21:32:54 2004 +0000 @@ -3774,6 +3774,30 @@ .PD 1 . .TP +.B \-aviaspect <w:h> +Encode an additional AVI header with aspect ratio. This is a different +method than the "aspect=..." option of libavcodec or xvid, and is +prioritized over it during playback, because this header is processed +first. + +This option is included for completeness. Some players can understand +it, while they do not understand the aspect headers produced by the +codec. If you wish to target such a player, use this +option. Generally, encoding AVIs with square pixels is still the best +choice, so aspect headers should be avoided. Use this option only if +you know what you are doing. Avoid using it together with +the aspect option of the codec, as it could bring unpredictable +results. + +.I EXAMPLE: +.PD 0 +.RSs +.IPs "\-aviaspect 16:9" +will add a header specifying 16:9 aspect ratio. +.RE +.PD 1 +. +.TP .B \-info <option1:option2:...> (AVI only) Specify the info header of the resulting AVI file. .br
--- a/cfg-mencoder.h Sun Mar 21 14:24:45 2004 +0000 +++ b/cfg-mencoder.h Sun Mar 21 21:32:54 2004 +0000 @@ -58,6 +58,8 @@ extern m_option_t xvidencopts_conf[]; #endif +extern float avi_prp_aspect; + extern m_option_t nuvopts_conf[]; m_option_t ovc_conf[]={ @@ -192,6 +194,9 @@ // override FOURCC in output file {"ffourcc", &force_fourcc, CONF_TYPE_STRING, 0, 4, 4, NULL}, + // avi muxer - include prp header with aspect ratio + {"aviaspect", &avi_prp_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 3.0, NULL}, + {"pass", "The -pass option is obsolete. Use -lavcopts vpass=n or -divx4opts pass=n!\nRTFM!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, {"passlogfile", &passtmpfile, CONF_TYPE_STRING, 0, 0, 0, NULL},
--- a/libmpdemux/muxer_avi.c Sun Mar 21 14:24:45 2004 +0000 +++ b/libmpdemux/muxer_avi.c Sun Mar 21 21:32:54 2004 +0000 @@ -34,6 +34,8 @@ #define ODML_NOTKEYFRAME 0x80000000U #define MOVIALIGN 0x00001000 +float avi_prp_aspect = -1.0; + struct avi_odmlidx_entry { uint64_t ofs; uint32_t len; @@ -223,12 +225,8 @@ #define WFSIZE(wf) (sizeof(WAVEFORMATEX)+(wf)->cbSize) -static unsigned int avi_aspect(sh_video_t *sh_video) +static unsigned int avi_aspect(float aspect) { - float aspect = sh_video->aspect; - if (aspect <= 0.0) { - aspect = (float)sh_video->disp_w/(float)sh_video->disp_h; - } if (aspect >= 3.99/3.0 && aspect <= 4.01/3.0) return MAKE_AVI_ASPECT(4,3); if (aspect >= 15.99/9.0 && @@ -247,6 +245,7 @@ muxer_info_t info[16]; FILE *f = muxer->file; VideoPropHeader vprp; + off_t pos; int isodml = muxer->file_end > ODML_CHUNKLEN ? 1 : 0; @@ -314,7 +313,9 @@ switch(muxer->streams[i]->type){ case MUXER_TYPE_VIDEO: hdrsize+=muxer->streams[i]->bih->biSize+8; // strf - hdrsize+=8+4*(9+8*1); // vprp + if (avi_prp_aspect > 0) { + hdrsize+=8+4*(9+8*1); // vprp + } break; case MUXER_TYPE_AUDIO: hdrsize+=WFSIZE(muxer->streams[i]->wf)+8; // strf @@ -347,20 +348,22 @@ s->h.fccHandler = s->bih->biCompression; s->h.rcFrame.right = s->bih->biWidth; s->h.rcFrame.bottom = s->bih->biHeight; - // 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(s->source); - vprp.dwFrameWidthInPixels = muxer->avih.dwWidth; - vprp.dwFrameHeightInLines = muxer->avih.dwHeight; - vprp.nbFieldPerFrame = 1; - vprp.FieldInfo[0].CompressedBMHeight = muxer->avih.dwHeight; - vprp.FieldInfo[0].CompressedBMWidth = muxer->avih.dwWidth; - vprp.FieldInfo[0].ValidBMHeight = muxer->avih.dwHeight; - vprp.FieldInfo[0].ValidBMWidth = muxer->avih.dwWidth; - hdrsize+=8+4*(9+8*1); // vprp + if (avi_prp_aspect > 0) { + // 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.dwFrameWidthInPixels = muxer->avih.dwWidth; + vprp.dwFrameHeightInLines = muxer->avih.dwHeight; + vprp.nbFieldPerFrame = 1; + vprp.FieldInfo[0].CompressedBMHeight = muxer->avih.dwHeight; + vprp.FieldInfo[0].CompressedBMWidth = muxer->avih.dwWidth; + vprp.FieldInfo[0].ValidBMHeight = muxer->avih.dwHeight; + vprp.FieldInfo[0].ValidBMWidth = muxer->avih.dwWidth; + hdrsize+=8+4*(9+8*1); // vprp + } break; case MUXER_TYPE_AUDIO: hdrsize+=WFSIZE(s->wf)+8; // strf @@ -379,14 +382,16 @@ int biSize=s->bih->biSize; le2me_BITMAPINFOHEADER(s->bih); write_avi_chunk(f,ckidSTREAMFORMAT,biSize,s->bih); /* BITMAPINFOHEADER */ - le2me_BITMAPINFOHEADER(s->bih); - 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 */ + if (avi_prp_aspect > 0) { + le2me_BITMAPINFOHEADER(s->bih); + 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 */ + } } break; case MUXER_TYPE_AUDIO: