[SOLVED] Resolution on SD MKV

Support forum for DGDecNV
Post Reply
DAE avatar
Guest 2
Posts: 903
Joined: Mon Sep 20, 2010 2:18 pm

[SOLVED] Resolution on SD MKV

Post by Guest 2 »

There is something that probably I am doing wrong but I am asking not to have doubts.

There is this SD source that is 1280x692:

https://openload.co/f/wobfOwA6EQU/Fantozzi692vs704.mkv

When I drop it in DGIndexNV, the title tells 1280x692 and it's ok.

When I go to cropping filter and I disable it, the title tells 1280x704.

If I go again into cropping filter, every kind of auto crop gives me 1280x704.

Is there something wrong or is it wanted?

I can uderstand with 1088 to 1080 but this should not apply to SD and not give resolution increase more than native one.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Resolution on SD MKV

Post by admin »

The coded size is 704 and the stream specifies cropping to 692, so the cropping is set up that way upon open. If you go into the Cropping dialog and disable that then it is subsequently ignored. Autocropping works only by detecting black areas.

So what is the problem?
DAE avatar
Guest 2
Posts: 903
Joined: Mon Sep 20, 2010 2:18 pm

Re: Resolution on SD MKV

Post by Guest 2 »

admin wrote:
Thu Apr 05, 2018 1:14 pm
The coded size is 704 and the stream specifies cropping to 692
As far as I can see, coded size is 692. That is the problem.

Can you explain me where is 704 specified and how to find that value, apart from DGIndexNV?

I have tried to demux elementary video stream and still tells me 692.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Resolution on SD MKV

Post by admin »

Healthy skepticism, I love it. Time for your AVC syntax lesson. :lol:

Here is the parsing of the first SPS for the stream:

tormento_sps.jpg

And here is how the coded height is derived:

Code: Select all

PicHeightInMapUnits = sps->pic_height_in_map_units_minus1 + 1;
FrameHeightInMbs = (2 - sps->frame_mbs_only_flag) * PicHeightInMapUnits;
coded_height = FrameHeightInMbs * 16;
So the coded height is (2 - 1) * (43 + 1) * 16 = 704. Note that 704 is a multiple of 16 while 692 is not.

There is additional syntax to define a cropping rectangle. See the next post.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Resolution on SD MKV

Post by admin »

Here is the full algorithm to get the cropped size:

Code: Select all

int SubWidthC;
int SubHeightC;

if (sps->chroma_format_idc == 0 && sps->separate_colour_plane_flag == 0) { //monochrome
    SubWidthC = SubHeightC = 0;
}
else if (sps->chroma_format_idc == 1 && sps->separate_colour_plane_flag == 0) { //4:2:0 
    SubWidthC = SubHeightC = 2;
}
else if (sps->chroma_format_idc == 2 && sps->separate_colour_plane_flag == 0) { //4:2:2 
    SubWidthC = 2;
    SubHeightC = 1;
}
else if (sps->chroma_format_idc == 3) { //4:4:4
    if (sps->separate_colour_plane_flag == 0) {
        SubWidthC = SubHeightC = 1;
    }
    else if (sps->separate_colour_plane_flag == 1) {
        SubWidthC = SubHeightC = 0;
    }
}

int PicWidthInMbs = sps->pic_width_in_mbs_minus1 + 1;

int PicHeightInMapUnits = sps->pic_height_in_map_units_minus1 + 1;
int FrameHeightInMbs = (2 - sps->frame_mbs_only_flag) * PicHeightInMapUnits;

int crop_left = 0;
int crop_right = 0;
int crop_top = 0;
int crop_bottom = 0;

if (sps->frame_cropping_flag) {
    crop_left = sps->frame_crop_left_offset;
    crop_right = sps->frame_crop_right_offset;
    crop_top = sps->frame_crop_top_offset;
    crop_bottom = sps->frame_crop_bottom_offset;
}

int width = PicWidthInMbs * 16 - SubWidthC * (crop_left + crop_right);
int height = FrameHeightInMbs * 16 - SubHeightC * (2 - sps->frame_mbs_only_flag) * (crop_top + crop_bottom);
I hope it is clear. Nothing is simple anymore in video compression. :(
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Resolution on SD MKV

Post by admin »

BTW, that parser application is ridiculously expensive ($60 per month :wow: ). I have a version from its freeware days. You can also run the debugger on the HM reference software in a pinch.
DAE avatar
Guest 2
Posts: 903
Joined: Mon Sep 20, 2010 2:18 pm

Re: [SOLVED] Resolution on SD MKV

Post by Guest 2 »

I am really really thankful for your explanation. :salute:
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: [SOLVED] Resolution on SD MKV

Post by admin »

Happy to be helpful!
Post Reply