[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 2116, Mon Jun 15 13:00:46 2015 UTC revision 2137, Tue Jan 12 13:55:05 2016 UTC
# Line 319  Line 319 
319    
320          m_tray_icon = 0;          m_tray_icon = 0;
321          m_startClock = clock();          m_startClock = clock();
322            interlaced = 0;
323    
324  #if defined(XVID_USE_MFT)  #if defined(XVID_USE_MFT)
325          InitializeCriticalSection(&m_mft_lock);          InitializeCriticalSection(&m_mft_lock);
# Line 728  Line 729 
729                          vih->dwPictAspectRatioY = abs(m_create.height);                          vih->dwPictAspectRatioY = abs(m_create.height);
730                          forced_ar = false;                          forced_ar = false;
731                  }                  }
732                    if (interlaced) {
733                            vih->dwInterlaceFlags = AMINTERLACE_IsInterlaced;
734                            if (interlaced > 1) {
735                                    vih->dwInterlaceFlags |= AMINTERLACE_Field1First;
736                            }
737                    }
738                    else {
739                            vih->dwInterlaceFlags = 0;
740                    }
741          } else {          } else {
742    
743                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));
# Line 1141  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 1154  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                                                            need_format_change = 1;
1175                                                    }
1176                                                    if ((interlaced) && !(vihOut2->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
1177                                                    {
1178                                                            vihOut2->dwInterlaceFlags = AMINTERLACE_IsInterlaced;
1179                                                            if (interlaced > 2) {
1180                                                                    vihOut2->dwInterlaceFlags |= AMINTERLACE_Field1First;
1181                                                            }
1182                                                            need_format_change = 1;
1183                                                    }
1184                                                    else if (!interlaced && !!(vihOut2->dwInterlaceFlags & AMINTERLACE_IsInterlaced)){
1185                                                            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 1224  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 1583  Line 1619 
1619          }          }
1620    
1621          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1622                    if (interlaced > 1) {
1623                            hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_FieldInterleavedUpperFirst);
1624                    }
1625                    else if (interlaced) {
1626                            hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_FieldInterleavedLowerFirst);
1627                    }
1628                    else {
1629                  hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);                  hr = pOutputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
1630          }          }
1631            }
1632    
1633          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1634                  hr = MFSetAttributeRatio(pOutputType, MF_MT_PIXEL_ASPECT_RATIO, ar_x, ar_y);                  hr = MFSetAttributeRatio(pOutputType, MF_MT_PIXEL_ASPECT_RATIO, ar_x, ar_y);
# Line 1961  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 2044  Line 2090 
2090                                  par_y = PARS[stats.data.vol.par-1][1];                                  par_y = PARS[stats.data.vol.par-1][1];
2091                          }                          }
2092    
2093                          ar_x = par_x * stats.data.vol.width;                          ar_x = par_x;
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;
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)) {
2100                            interlaced = (stats.data.vop.general & XVID_VOP_TOPFIELDFIRST) ? 2 : 1;
2101                            need_format_change = 1;
2102                    }
2103                    else {
2104                            if (interlaced > 0) {
2105                                    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 2075  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;
# Line 2151  Line 2236 
2236    
2237                  convert.width = m_create.width;                  convert.width = m_create.width;
2238                  convert.height = m_create.height;                  convert.height = m_create.height;
2239                  convert.interlacing = 0;                  convert.interlacing = (interlaced > 0) ? 1 : 0;
2240    
2241                  if (m_frame.output.plane[1] != NULL && Dst != NULL && xvid_global_func != NULL)                  if (m_frame.output.plane[1] != NULL && Dst != NULL && xvid_global_func != NULL)
2242                          if (xvid_global_func(0, XVID_GBL_CONVERT, &convert, NULL) < 0) /* CSP convert into output buffer */                          if (xvid_global_func(0, XVID_GBL_CONVERT, &convert, NULL) < 0) /* CSP convert into output buffer */

Legend:
Removed from v.2116  
changed lines
  Added in v.2137

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