[svn] / branches / release-1_3-branch / xvidcore / dshow / src / CXvidDecoder.cpp Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/dshow/src/CXvidDecoder.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2131, Fri Jan 8 17:44:53 2016 UTC revision 2135, Mon Jan 11 17:02:47 2016 UTC
# Line 1151  Line 1151 
1151                  {                  {
1152              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
1153                          return S_FALSE;                          return S_FALSE;
1154                  } else                  } else if ((g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1 && forced_ar == false) || !!(interlaced)){
                         if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1 && forced_ar == false) {  
1155    
1156        if (stats.type != XVID_TYPE_NOTHING) {  /* dont attempt to set vmr aspect ratio if no frame was returned by decoder */        if (stats.type != XVID_TYPE_NOTHING) {  /* dont attempt to set vmr aspect ratio if no frame was returned by decoder */
1157                          // inspired by minolta! works for VMR 7 + 9                          // inspired by minolta! works for VMR 7 + 9
# Line 1164  Line 1163 
1163                                  CMediaType mtOut2 = m_pOutput->CurrentMediaType();                                  CMediaType mtOut2 = m_pOutput->CurrentMediaType();
1164                                  VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format();                                  VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format();
1165    
1166                                  if (*mtOut2.FormatType() == FORMAT_VideoInfo2 &&                                          if (*mtOut2.FormatType() == FORMAT_VideoInfo2)
1167                                          vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y)                                          {
1168                                                    int need_format_change = 0;
1169    
1170                                                    if (vihOut2->dwPictAspectRatioX != ar_x || vihOut2->dwPictAspectRatioY != ar_y)
1171                                  {                                  {
1172                                          vihOut2->dwPictAspectRatioX = ar_x;                                          vihOut2->dwPictAspectRatioX = ar_x;
1173                                          vihOut2->dwPictAspectRatioY = ar_y;                                          vihOut2->dwPictAspectRatioY = ar_y;
1174                                          if (interlaced) {                                                          need_format_change = 1;
1175                                                    }
1176                                                    if ((interlaced) && !(vihOut2->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
1177                                                    {
1178                                                  vihOut2->dwInterlaceFlags = AMINTERLACE_IsInterlaced;                                                  vihOut2->dwInterlaceFlags = AMINTERLACE_IsInterlaced;
1179                                                  if (interlaced > 2) {                                                  if (interlaced > 2) {
1180                                                          vihOut2->dwInterlaceFlags |= AMINTERLACE_Field1First;                                                          vihOut2->dwInterlaceFlags |= AMINTERLACE_Field1First;
1181                                                  }                                                  }
1182                                                            need_format_change = 1;
1183                                          }                                          }
1184                                          else {                                                  else if (!interlaced && !!(vihOut2->dwInterlaceFlags & AMINTERLACE_IsInterlaced)){
1185                                                  vihOut2->dwInterlaceFlags = 0;                                                  vihOut2->dwInterlaceFlags = 0;
1186                                                            need_format_change = 1;
1187                                          }                                          }
1188    
1189                                                    if (need_format_change) {
1190                                          pOut2->SetMediaType(&mtOut2);                                          pOut2->SetMediaType(&mtOut2);
1191                                          m_pOutput->SetMediaType(&mtOut2);                                          m_pOutput->SetMediaType(&mtOut2);
1192                                  }                                  }
1193                                            }
1194                                  pOut2->Release();                                  pOut2->Release();
1195                          }                          }
1196        }        }
# Line 1243  Line 1253 
1253                          ar_y = par_y * stats.data.vol.height;                          ar_y = par_y * stats.data.vol.height;
1254                  }                  }
1255    
1256                    if (!!(stats.data.vol.general & XVID_VOL_INTERLACING)) {
1257                            interlaced = (stats.data.vop.general & XVID_VOP_TOPFIELDFIRST) ? 2 : 1;
1258                    }
1259                    else if (interlaced > 0) {
1260                            interlaced = 0;
1261                    }
1262    
1263                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
1264                  m_frame.length -= length;                  m_frame.length -= length;
1265                  goto repeat;                  goto repeat;
# Line 1988  Line 2005 
2005          HRESULT hr = S_OK;          HRESULT hr = S_OK;
2006          IMFMediaBuffer *pBuffer;          IMFMediaBuffer *pBuffer;
2007    
2008            int need_format_change = 0;
2009    
2010          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
2011                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);
2012          }          }
# Line 2072  Line 2091 
2091                          }                          }
2092    
2093                          ar_x = par_x * stats.data.vol.width;                          ar_x = par_x * stats.data.vol.width;
2094                          ar_y = par_y * stats.data.vol.height; /* TODO: Actually set the newly determined AR on the output sample type                          ar_y = par_y * stats.data.vol.height;
2095                                                                                                             or it'll have no effect at all... */  
2096                            need_format_change = 1;
2097                  }                  }
2098    
2099                  if (stats.data.vol.general & XVID_VOL_INTERLACING) {                  if (!!(stats.data.vol.general & XVID_VOL_INTERLACING)) {
2100                          interlaced = (stats.data.vop.general & XVID_VOP_TOPFIELDFIRST) ? 2 : 1;                          interlaced = (stats.data.vop.general & XVID_VOP_TOPFIELDFIRST) ? 2 : 1;
2101                            need_format_change = 1;
2102                  }                  }
2103                  else {                  else {
2104                            if (interlaced > 0) {
2105                          interlaced = 0;                          interlaced = 0;
2106                                    need_format_change = 1;
2107                            }
2108                  }                  }
2109    
2110                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
# Line 2109  Line 2133 
2133                  }                  }
2134          }          }
2135    
2136            if (need_format_change) {
2137                    IMFMediaType *pOutputType = NULL;
2138                    hr = MFTGetOutputCurrentType(0, &pOutputType);
2139    
2140                    if (SUCCEEDED(hr)) {
2141                    if (interlaced > 1) {
2142                            hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_FieldInterleavedUpperFirst);
2143                        }
2144                        else if (interlaced) {
2145                            hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_FieldInterleavedLowerFirst);
2146                        }
2147                        else {
2148                            hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
2149                        }
2150                    }
2151    
2152                    if (SUCCEEDED(hr)) {
2153                        hr = MFSetAttributeRatio(pOutputType, MF_MT_PIXEL_ASPECT_RATIO, ar_x, ar_y);
2154                    }
2155    
2156                    if (SUCCEEDED(hr)) {
2157                            MFTSetOutputType(0, pOutputType, 0);
2158                    }
2159    
2160                    if (pOutputType) pOutputType->Release();
2161            }
2162    
2163          LeaveCriticalSection(&m_mft_lock);          LeaveCriticalSection(&m_mft_lock);
2164    
2165          return hr;          return hr;

Legend:
Removed from v.2131  
changed lines
  Added in v.2135

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4