[svn] / trunk / xvidcore / dshow / src / CXvidDecoder.cpp Repository:
ViewVC logotype

Diff of /trunk/xvidcore/dshow/src/CXvidDecoder.cpp

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

revision 2133, Fri Jan 8 18:01:44 2016 UTC revision 2134, Mon Jan 11 17:02:15 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) {                                                          int format_change;
1175                                                    }
1176    
1177                                                    if ((interlaced) && !(vihOut2->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
1178                                                    {
1179                                                  vihOut2->dwInterlaceFlags = AMINTERLACE_IsInterlaced;                                                  vihOut2->dwInterlaceFlags = AMINTERLACE_IsInterlaced;
1180                                                  if (interlaced > 2) {                                                  if (interlaced > 2) {
1181                                                          vihOut2->dwInterlaceFlags |= AMINTERLACE_Field1First;                                                          vihOut2->dwInterlaceFlags |= AMINTERLACE_Field1First;
1182                                                  }                                                  }
1183                                                            need_format_change = 1;
1184                                          }                                          }
1185                                          else {                                                  else if (!interlaced && !!(vihOut2->dwInterlaceFlags & AMINTERLACE_IsInterlaced)){
1186                                                  vihOut2->dwInterlaceFlags = 0;                                                  vihOut2->dwInterlaceFlags = 0;
1187                                                            need_format_change = 1;
1188                                          }                                          }
1189    
1190                                                    if (need_format_change) {
1191                                          pOut2->SetMediaType(&mtOut2);                                          pOut2->SetMediaType(&mtOut2);
1192                                          m_pOutput->SetMediaType(&mtOut2);                                          m_pOutput->SetMediaType(&mtOut2);
1193                                  }                                  }
1194                                            }
1195                                  pOut2->Release();                                  pOut2->Release();
1196                          }                          }
1197        }        }
# Line 1243  Line 1254 
1254                          ar_y = par_y * stats.data.vol.height;                          ar_y = par_y * stats.data.vol.height;
1255                  }                  }
1256    
1257                    if (!!(stats.data.vol.general & XVID_VOL_INTERLACING)) {
1258                            interlaced = (stats.data.vop.general & XVID_VOP_TOPFIELDFIRST) ? 2 : 1;
1259                    }
1260                    else if (interlaced > 0) {
1261                            interlaced = 0;
1262                    }
1263    
1264                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
1265                  m_frame.length -= length;                  m_frame.length -= length;
1266                  goto repeat;                  goto repeat;
# Line 1988  Line 2006 
2006          HRESULT hr = S_OK;          HRESULT hr = S_OK;
2007          IMFMediaBuffer *pBuffer;          IMFMediaBuffer *pBuffer;
2008    
2009            int need_format_change = 0;
2010    
2011          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
2012                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);
2013          }          }
# Line 2072  Line 2092 
2092                          }                          }
2093    
2094                          ar_x = par_x * stats.data.vol.width;                          ar_x = par_x * stats.data.vol.width;
2095                          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;
2096                                                                                                             or it'll have no effect at all... */  
2097                            need_format_change = 1;
2098                  }                  }
2099    
2100                  if (stats.data.vol.general & XVID_VOL_INTERLACING) {                  if (!!(stats.data.vol.general & XVID_VOL_INTERLACING)) {
2101                          interlaced = (stats.data.vop.general & XVID_VOP_TOPFIELDFIRST) ? 2 : 1;                          interlaced = (stats.data.vop.general & XVID_VOP_TOPFIELDFIRST) ? 2 : 1;
2102                            need_format_change = 1;
2103                  }                  }
2104                  else {                  else {
2105                            if (interlaced > 0) {
2106                          interlaced = 0;                          interlaced = 0;
2107                                    need_format_change = 1;
2108                            }
2109                  }                  }
2110    
2111                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
# Line 2109  Line 2134 
2134                  }                  }
2135          }          }
2136    
2137            if (need_format_change) {
2138                    IMFMediaType *pOutputType = NULL;
2139                    hr = MFTGetOutputCurrentType(0, &pOutputType);
2140    
2141                    if (SUCCEEDED(hr)) {
2142                            if (interlaced > 1) {
2143                                    hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_FieldInterleavedUpperFirst);
2144                            }
2145                            else if (interlaced) {
2146                                    hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_FieldInterleavedLowerFirst);
2147                            }
2148                            else {
2149                                    hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
2150                            }
2151                    }
2152    
2153                    if (SUCCEEDED(hr)) {
2154                            hr = MFSetAttributeRatio(pOutputType, MF_MT_PIXEL_ASPECT_RATIO, ar_x, ar_y);
2155                    }
2156    
2157                    if (SUCCEEDED(hr)) {
2158                            MFTSetOutputType(0, pOutputType, 0);
2159                    }
2160    
2161                    if (pOutputType) pOutputType->Release();
2162            }
2163    
2164          LeaveCriticalSection(&m_mft_lock);          LeaveCriticalSection(&m_mft_lock);
2165    
2166          return hr;          return hr;

Legend:
Removed from v.2133  
changed lines
  Added in v.2134

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