Using subframe is a bit tricky here, since MPEG2DEC writes full resolution to the AviSynth PVideoFrame.
You would have to create a separate full-resolution videoframe, and returning the cropped one to AviSynth in the constructor.
The full resolution VideoFrame should be used for the env->NewVideoFrame(vi), that constructs the output frame for MPEG2DEC. Then the subframe function can be used to return the cropped version, that correspons with the VideoInfo returned by the constructor.
transform.cpp / Crop function can of course be used as a reference here.
Oh - This is actually the hard way of doing this. The easiest way is probably to invoke the internal crop filter:
in AVISynthAPI.cpp:
Code:
AVSValue mpegS = new MPEG2Source(
args[0].AsString(d2v),
args[1].AsInt(cpu),
args[2].AsInt(idct),
args[3].AsBool(iPP),
args[4].AsInt(moderate_h),
args[5].AsInt(moderate_v),
args[6].AsBool(showQ),
args[7].AsBool(fastMC),
args[8].AsString(cpu2),
env);
AVSValue CropArgs[5] = {mpegS.AsClip(),10,10,-10,-10};
return env->Invoke("crop",AVSValue(CropArgs,5));
Fill in crop args as you please. I haven't had time to test it, but it compiles and should work fine. Leaving my previous ramblings for you, so you can see why SubFrame gives you problems.