Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-2 Encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd October 2013, 16:41   #1  |  Link
hank315
HCenc author
 
Join Date: Nov 2003
Location: Netherlands
Posts: 570
HCenc 027

After a long time an update:

HCenc 0.27 beta - release date 21-10-2013

- support for YV16 (4:2:2) and YV24 (4:4:4) colorspace
- lossless intermediate mode implemented for all colorspaces
- Avisynth script written in logfile
- some more bugs solved

For colorspace YV16 and YV24 Avisynth 2.6 is needed, Avisynth 2.5 doesn't recognize YV16/YV24 colorspace.
HCenc doesn't upsample chroma so for 4:4:4 output you need YV24 input.
HCenc can subsample chroma, so for instance YV24 input can be subsampled to 4:2:0 output, using progressive or interlaced subsampling.
Of course you can also use the upsampling/subsampling functions of Avisynth 2.6.
__________________
HCenc at: http://hank315.nl
hank315 is offline   Reply With Quote
Old 22nd October 2013, 17:10   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Sweet! Thank you, Hank.

Questions: are the GUI and encoder combined in one EXE now? All I see in your ZIP is the single EXE. And what about the matrices, the DGDecode stuff, etc.?

Last edited by Guest; 22nd October 2013 at 17:13.
Guest is offline   Reply With Quote
Old 22nd October 2013, 17:50   #3  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Taken from the "Notes" section for 0.27 beta:

Quote:
- only encoder, still working on the GUI
Looks like you need to use the GUI and all the other extras from the previous version...


@Hank
Thanks very much for the new version...

Could you elaborate a little on this:
Quote:
- some more bugs solved
Since I have no use for the new colorspace features I'd like to know if I should upgrade from version 0.26.



Cheers
manolito
manolito is offline   Reply With Quote
Old 22nd October 2013, 18:56   #4  |  Link
hank315
HCenc author
 
Join Date: Nov 2003
Location: Netherlands
Posts: 570
It's the encoder only, still working on the GUI.
So the HC.ini must be edited by hand but I hope to finish the complete package soon.
For now I will add the DGdecode.dll to the zip-file.

If you don't need the new colorspaces then there's no real need for this new beta version.
About the bugs, two come to mind:
- lossless intermediate mode is fixed for YUY2 input
- small error in the calculation of the Macro Block variance (used for adaptive quantization decision) fixed
and some more I already forgot.
__________________
HCenc at: http://hank315.nl
hank315 is offline   Reply With Quote
Old 23rd October 2013, 07:39   #5  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 940
For "Avisynth script written in logfile".
Millions of small test samples will definitely come in handy now.
__________________
Win10 (x64) build 19041
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
Sparktank is offline   Reply With Quote
Old 24th October 2013, 01:05   #6  |  Link
hank315
HCenc author
 
Join Date: Nov 2003
Location: Netherlands
Posts: 570
HC027 updated, now also includes GUI.
__________________
HCenc at: http://hank315.nl
hank315 is offline   Reply With Quote
Old 24th October 2013, 03:43   #7  |  Link
filler56789
SuperVirus
 
filler56789's Avatar
 
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
Quote:
Originally Posted by hank315 View Post
HC027 updated, now also includes GUI.
filler56789 is offline   Reply With Quote
Old 24th October 2013, 10:18   #8  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,997
Thank you hank315!
Sharc is offline   Reply With Quote
Old 25th October 2013, 00:44   #9  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,419
0.27 is exhibiting an error involving FFMS2 and AviSynth 2.6. The script is being detected as 4:4:4 even though the video file being served in is 4:2:0, and I'm not doing any colorspace conversions at all (I even went so far as to append ConvertToYV12 to the end of the script, and it still registered as 4:4:4). Converting the input to AVI first and running it through AVISource instead allows 0.27 to work as expected.

Initially I encountered the problem on our iMac (with a Sandy Bridge i5) running everything under Wine, but the window closed too quickly to see the error. Testing it on my old Pentium III I could see the 4:4:4 issue. Seen with AviSynth 2.6 MT 2013.03.09 and 2013.09.28, AviSynth 2.6a5, and AviSynth+ 2013.10.16.
qyot27 is offline   Reply With Quote
Old 25th October 2013, 04:23   #10  |  Link
Fishman0919
FishmanMod Android Dev
 
Fishman0919's Avatar
 
Join Date: Apr 2004
Location: Somewhere else, maybe Arizona Bay
Posts: 1,143
@hank315

Thank You kind Sir!
__________________
"Cinderella story, out of nowhere,
former greenskeeper, now about
to become the Masters champion.
It looks like a mirac- it's in the hole!"
Fishman0919 is offline   Reply With Quote
Old 25th October 2013, 11:38   #11  |  Link
Darksoul71
Can you blush ?
 
Darksoul71's Avatar
 
Join Date: Oct 2001
Location: Northern Europe
Posts: 696
Quote:
Originally Posted by hank315 View Post
HC027 updated, now also includes GUI.
Darksoul71 is offline   Reply With Quote
Old 25th October 2013, 12:29   #12  |  Link
hank315
HCenc author
 
Join Date: Nov 2003
Location: Netherlands
Posts: 570
@qyot27

I can replicate it, investigating...
__________________
HCenc at: http://hank315.nl
hank315 is offline   Reply With Quote
Old 25th October 2013, 16:11   #13  |  Link
hank315
HCenc author
 
Join Date: Nov 2003
Location: Netherlands
Posts: 570
Next findings using avisynth 2.6 alpha 5 and FFMS2 2.19

Code:
    ...
    *Chroma_info = 0;
    if (clip->GetVideoInfo().IsYV12())  *Chroma_info = 1;
    if (clip->GetVideoInfo().IsYUY2())  *Chroma_info = 2;
    if (clip->GetVideoInfo().IsYV16())  *Chroma_info = 3;
    if (clip->GetVideoInfo().IsYV24())  *Chroma_info = 4;
    return 0;
is part of the HCenc code.
return(0) means the function returns without errors, *Chroma_info is a function argument.

I never used FFMS2 before so I know nothing about it.
FFMS2 with YV12 (4:2:0) source returns the next values:
Code:
    clip->GetVideoInfo().IsYV12() = TRUE
    clip->GetVideoInfo().IsYUY2() = FALSE
    clip->GetVideoInfo().IsYV16() = TRUE
    clip->GetVideoInfo().IsYV24() = TRUE
*Chroma_info = 4 is set, so HCenc thinks the source is 4:4:4 and will crash.
Perhaps the FFMS2 developers can shed some light on this.
__________________
HCenc at: http://hank315.nl
hank315 is offline   Reply With Quote
Old 25th October 2013, 18:06   #14  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by hank315 View Post
FFMS2 with YV12 (4:2:0) source returns the next values:
Code:
    clip->GetVideoInfo().IsYV12() = TRUE
    clip->GetVideoInfo().IsYUY2() = FALSE
    clip->GetVideoInfo().IsYV16() = TRUE
    clip->GetVideoInfo().IsYV24() = TRUE
Just tried this with a little test program and I get FALSE for both YV16 and YV24.
Maybe IanB can help out with this.
Groucho2004 is offline   Reply With Quote
Old 25th October 2013, 21:43   #15  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
How are you handling the AVS_linkage pointer?

Applications loading Avisynth.dll as a library need to set the AVS_linkage pointer as the very next thing after getting the IScriptEnvironment from CreateScriptEnvironment with env->GetAVSLinkage().



Also a more future proof style might be to use vi.IsPlanar with vi.GetPlaneWidthSubsampling and vi.GetPlaneHeightSubsampling. The current version only allows YV12, YV16, YV24 and YV411 but the hope is to allow arbitrary H and V chroma subsampling.
IanB is offline   Reply With Quote
Old 25th October 2013, 22:15   #16  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
In case you're interested, here is some sample code using the new API that has been working well for me:
Code:
#include <windows.h>
#include <wintrust.h>
#include <imagehlp.h>
#include <string>
#include "avisynth26.h"

BOOL AvisynthExportsAVSLinkage();
const AVS_Linkage *AVS_linkage = 0;

int main(int argc, char* argv[])
{
 //Check if avisynth exports "AVS_Linkage" to make sure at least Avisynth 2.6 Alpha 4 is used
 if (!AvisynthExportsAVSLinkage())
 {
  printf("\nAvisynth 2.6 (Alpha 4 and above) is required.\n");
  return -1;
 }

 HINSTANCE hDLL = ::LoadLibrary("avisynth");
 if (!hDLL)
 {
  cs_avserror = "Failed to load avisynth.dll";
  return -1;
 }

 try 
 {
  IScriptEnvironment *(__stdcall *CreateEnvironment)(int) = (IScriptEnvironment *(__stdcall *)(int))::GetProcAddress(hDLL, "CreateScriptEnvironment");
  if (!CreateEnvironment)
  {
   printf("\nFailed to load CreateScriptEnvironment()\n");
   ::FreeLibrary(hDLL);
   return -1;
  }
 
  IScriptEnvironment *AVS_env = CreateEnvironment(AVISYNTH_INTERFACE_VERSION);
  if (!AVS_env)
  {
   printf("\nCould not create IScriptenvironment\n");
   ::FreeLibrary(hDLL);
   return -1;
  }

  AVS_linkage = AVS_env->GetAVSLinkage();

  AVSValue AVS_main;
  AVS_main = AVS_env->Invoke("Import", argv[1]);

  if (!AVS_main.IsClip()) //not a clip
   AVS_env->ThrowError("Script did not return a video clip:\n(%s)", argv[1]);

  PClip AVS_clip;
  PVideoFrame AVS_frame;
  VideoInfo AVS_vidinfo;

  AVS_clip = AVS_main.AsClip();
  AVS_vidinfo = AVS_clip->GetVideoInfo();
  unsigned int uiFrames = (unsigned int)AVS_vidinfo.num_frames;

  //read frames
  for (unsigned int n = 0; n < uiFrames; n++)
  {
   AVS_frame = AVS_clip->GetFrame(n, AVS_env);
   //...
   //...
  }

  AVS_frame = 0;
  AVS_clip = 0;
  AVS_main = 0;
  AVS_env->DeleteScriptEnvironment();
 }
 catch(AvisynthError err) 
 {
  //...
 }

 AVS_linkage = 0;
 ::FreeLibrary(hDLL);

 return 0;
}


BOOL AvisynthExportsAVSLinkage()
{
 BOOL bRet = FALSE;

 LOADED_IMAGE li;
 BOOL bLoaded = MapAndLoad("avisynth", NULL, &li, TRUE, TRUE);
 if (!bLoaded)
  return bRet;

 DWORD expVA = li.FileHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
 PIMAGE_EXPORT_DIRECTORY pExp = (PIMAGE_EXPORT_DIRECTORY)ImageRvaToVa(li.FileHeader, li.MappedAddress, expVA, NULL);

 DWORD rvaNames = pExp->AddressOfNames;
 DWORD *prvaNames = (DWORD*)ImageRvaToVa(li.FileHeader, li.MappedAddress, rvaNames, NULL);
 string sName = "";
 int iPos = 0;

 for (DWORD i = 0; i < pExp->NumberOfNames; ++i)
 {
  DWORD rvaName = prvaNames[i];
  sName = (char *)ImageRvaToVa(li.FileHeader, li.MappedAddress, rvaName, NULL);
  iPos = (int)sName.find("AVS_Linkage");
  if (iPos >= 0)
  {
   bRet = TRUE;
   break;
  }
 }

 UnMapAndLoad(&li);

 return bRet;
}

Last edited by Groucho2004; 25th October 2013 at 22:20.
Groucho2004 is offline   Reply With Quote
Old 25th October 2013, 23:18   #17  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Since I still use AviSynth version 2.57 which does not support these new colorspaces I (falsely) assumed that I was safe from this 4:4:4 error.

Obviously I was wrong. When I try to convert some file using either ffms2 2.17 or 2.19 (plain vanilla 32bit), HC crashes with this 4:4:4 error. Strange...


Cheers
manolito
manolito is offline   Reply With Quote
Old 26th October 2013, 09:08   #18  |  Link
Taurus
Registered User
 
Taurus's Avatar
 
Join Date: Mar 2002
Location: Krautland
Posts: 903
Same here...Crash

ffms2 2.16, 2.17 or 2.19 on standard AviSynth version 2.58.
No MT, 32bit.

The same scripts are working reliable on HCenc 025/026.
Taurus is offline   Reply With Quote
Old 26th October 2013, 21:38   #19  |  Link
hank315
HCenc author
 
Join Date: Nov 2003
Location: Netherlands
Posts: 570
Thanks for comments and advice.
A new package is uploaded but for now without the support of YV16 and YV24.
I hope to add YV16 and YV24 soon but then working properly.

@Groucho2004
Thanks, that code certainly helps.
__________________
HCenc at: http://hank315.nl
hank315 is offline   Reply With Quote
Old 26th October 2013, 23:39   #20  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
An easier way to check for AvisynthExportsAVSLinkage instead of parsing the .dll export table would be just to do a ::GetProcAddress(hDLL, "AVS_Linkage"). The value returned is the address of the linkage table, but it's probably not a good idea to rely on this behaviour, instead use the "not found" error for detecting incompatible versions.

Seems I need to bump the interface version to 6 to avoid the confusion at present when I freeze the API design for release candidates.
IanB is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.