Ticket #2198: 1080iTranscode.20060821.patch

File 1080iTranscode.20060821.patch, 4.5 KB (added by wagspat@…, 18 years ago)

updated patch against SVN version 10860

  • programs/mythtranscode/transcode.cpp

     
    383383
    384384    int video_width = nvp->GetVideoWidth();
    385385    int video_height = nvp->GetVideoHeight();
     386     
     387    if (video_height == 1088) {
     388       VERBOSE(VB_IMPORTANT, QString("Unlikely the video height really is 1088, using hacks..."));
     389    }
     390
    386391    float video_aspect = nvp->GetVideoAspect();
    387392    float video_frame_rate = nvp->GetFrameRate();
    388393    int newWidth = video_width;
     
    415420        }
    416421        else if (profile.byName("transcoderesize")->getValue().toInt())
    417422        {
     423            int fudge1080 = (video_height == 1088 ? 8 : 0);
     424
    418425            nvp->SetVideoFilters(vidfilters);
    419426            newWidth = profile.byName("width")->getValue().toInt();
    420427            newHeight = profile.byName("height")->getValue().toInt();
    421428
    422429            // If height or width are 0, then we need to calculate them
    423430            if (newHeight == 0 && newWidth > 0)
    424                 newHeight = (int)(1.0 * newWidth * video_height / video_width);
     431                newHeight = (int)(1.0 * newWidth * (video_height-fudge1080) / video_width);
    425432            else if (newWidth == 0 && newHeight > 0)
    426                 newWidth = (int)(1.0 * newHeight * video_width / video_height);
     433                newWidth = (int)(1.0 * newHeight * video_width / (video_height-fudge1080));
    427434            else if (newWidth == 0 && newHeight == 0)
    428435            {
    429436                newHeight = 480;
    430                 newWidth = (int)(1.0 * 480 * video_width / video_height);
     437                newWidth = (int)(1.0 * 480 * video_width / (video_height-fudge1080));
    431438                if (newWidth > 640)
    432439                {
    433440                    newWidth = 640;
    434                     newHeight = (int)(1.0 * 640 * video_height / video_width);
     441                    newHeight = (int)(1.0 * 640 * (video_height-fudge1080) / video_width);
    435442                }
    436443            }
    437 
    438444            if (encodingType.left(4).lower() == "mpeg")
    439445            {
    440446                // make sure dimensions are valid for MPEG codecs
    441447                newHeight = (newHeight + 15) & ~0xF;
    442448                newWidth  = (newWidth  + 15) & ~0xF;
    443449            }
    444 
    445450            VERBOSE(VB_IMPORTANT, QString("Resizing from %1x%2 to %3x%4")
    446451                    .arg(video_width).arg(video_height)
    447452                    .arg(newWidth).arg(newHeight));
     
    786791                                   video_width, video_height);
    787792                    avpicture_fill(&imageOut, frame.buf, PIX_FMT_YUV420P,
    788793                                   newWidth, newHeight);
    789                     scontext = img_resample_init(newWidth, newHeight,
    790                                                  video_width, video_height);
     794                    if (video_height != 1088) {
     795                        scontext = img_resample_init(newWidth, newHeight,
     796                                                     video_width, video_height);
     797                    } else {
     798                        scontext = img_resample_full_init(newWidth, newHeight,
     799                                                          video_width, video_height,
     800                                                          0,8,0,0,
     801                                                          0,0,0,0);
     802                    }
    791803                    img_resample(scontext, &imageOut, &imageIn);
    792804                    img_resample_close(scontext);
    793805                }
     
    832844                               video_width, video_height);
    833845                avpicture_fill(&imageOut, frame.buf, PIX_FMT_YUV420P,
    834846                               newWidth, newHeight);
    835                 scontext = img_resample_init(newWidth, newHeight,
    836                                              video_width, video_height);
     847                if (video_height != 1088) {
     848                    scontext = img_resample_init(newWidth, newHeight,
     849                                                 video_width, video_height);
     850                }
     851                else
     852                {
     853                    scontext = img_resample_full_init(newWidth, newHeight,
     854                                                      video_width, video_height,
     855                                                      0,8,0,0,
     856                                                      0,0,0,0);
     857                }
     858 
    837859                img_resample(scontext, &imageOut, &imageIn);
    838860                img_resample_close(scontext);
    839861            }