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-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th June 2005, 11:14   #1  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779
interlaced avc

ok with starting to analyse a bunch of avc hdtv samples i wondered about how interlaced is handled in avc:

there are four types of interlacing possible it seems:
1) interlaced (which means that all frames get interlaced)
2) paff: a mix of interlaced and progressive frames
3) mbaff: a mix of interlaced and progressive macroblocks in each frame
4) a mix of interlaced and mbaff frames


how to detect the interlacing used on an existing stream:
- progressive is signalled by setting frame_mbs_only_flag: 1 in the SPS
- interlaced is signalled by setting frame_mbs_only_flag: 0 in the SPS and field_pic_flag: 1 on all frames
- paff is signalled by setting frame_mbs_only_flag: 0 in the SPS and field_pic_flag: 1 on all frames that get interlaced and field_pic_flag: 0 on all frames that get progressive
- mbaff is signalled by setting frame_mbs_only_flag: 0 and mb_adaptive_frame_field_flag: 1 in the SPS and field_pic_flag: 0 on the frames (field_pic_flag: 1 would indicate a normal interlaced frame)

the mode of interlacing can be changed between the different SPSs


now my questions:
1) is this correct
2) regarding paff: can progressive and interlaced frames varry in one SPS sequence or only between different SPS sequences (one SPS seq is fully interlaced, another one is fully progressive)
3) how does the field_pic_flag need to be set on mbaff-only streams (so no mix with paff)?
4) a stream having frame_mbs_only_flag: 0 but still also all frames with field_pic_flag: 0 would be a normal progressive stream?

thx for the answers
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 29th June 2005 at 22:01.
bond is offline   Reply With Quote
Old 29th June 2005, 16:57   #2  |  Link
kwtc
Registered User
 
Join Date: Sep 2004
Location: Yvelines
Posts: 30
  1. Perfect !
  2. With PAFF, one can select progressive or interlaced for every frame, hence the same sequence may contain both types.
  3. Mbaff frames are coded with field_pic_flag equal 0. Otherwise the frame is coded as two fields (usual interlaced), thus mixing mbaff + interlaced. However, it is
    not possible in the same sequence to mix mbaff frames and normal progressive frames.
  4. Yes.

In other words
- frame_mbs_only_flag = 1 means progressive frames only.
- mb_adaptive_frame_field_flag = 1 means that pictures encoded with filed_pic_flag = 0 will use mbaff
- field_pic_flag = 1 means that the picture is encoded as two interlaced fields.
kwtc is offline   Reply With Quote
Old 29th June 2005, 18:36   #3  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779
Quote:
Originally Posted by kwtc
Mbaff frames are coded with field_pic_flag equal 0. Otherwise the frame is coded as two fields (usual interlaced), thus mixing mbaff + interlaced. However, it is not possible in the same sequence to mix mbaff frames and normal progressive frames.
ok i see

so a frame with frame_mbs_only_flag: 0 and mb_adaptive_frame_field_flag: 1 and field_pic_flag: 1 will be a normal interlaced frame

why is it not possible to mix mbaff frames and progressive frames?

what about multisliced frames? is each slice treated like an own frame or are all slices which build a frame treated together as one frame?

thx for your answers!!
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 29th June 2005 at 18:43.
bond is offline   Reply With Quote
Old 29th June 2005, 19:57   #4  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,312
Just curious. What's the idea of interlacing on the macroblock level?
Wilbert is offline   Reply With Quote
Old 29th June 2005, 20:34   #5  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779
Quote:
Originally Posted by Wilbert
Just curious. What's the idea of interlacing on the macroblock level?
increased coding efficiency (aka lower bitrate needed) compared to normal interlacing or paff
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 30th June 2005, 14:59   #6  |  Link
Gusto
Registered User
 
Join Date: Feb 2004
Location: Warsaw, Poland
Posts: 8
Quote:
Originally Posted by bond
increased coding efficiency (aka lower bitrate needed) compared to normal interlacing or paff
I think it's exactly the opposite: MBAFF introduces some more bins/bits per MB compared to interlace, where this information is gathered on a higer level.

Best,
Gusto is offline   Reply With Quote
Old 30th June 2005, 15:40   #7  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Gusto : indeed, MBaff adds 1 bit per 2MBs in order to signal whether the 2MBs will be field or frame. But firstly, this bit, in cabac, will take less than 1 bit in average. Secondly, encoding the pair of macroblocks in the correct mode doesn't increase the size, it reduces it. And it reduces it by far more than 1 bit.
Manao is offline   Reply With Quote
Old 30th June 2005, 16:21   #8  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,923
Maybe this can enlighten you:

http://neuron2.net/guest/H264.pdf
Guest is offline   Reply With Quote
Old 1st July 2005, 01:59   #9  |  Link
hworldjj
Registered User
 
Join Date: Sep 2004
Posts: 17
Quote:
Originally Posted by Gusto
I think it's exactly the opposite: MBAFF introduces some more bins/bits per MB compared to interlace, where this information is gathered on a higer level.

Best,
For interlaced movie, mbaff is definitely better than just frame mode because the correlation between the adjacent lines of the pictures is low in high motion regions. If the picture is arranged into two fields, the efficiency of dct and ME will be improved. This is the turth for MPEG-2 and H.264 and you can analyze the commecial DVDs

hworldjj
hworldjj is offline   Reply With Quote
Old 1st July 2005, 09:49   #10  |  Link
Gusto
Registered User
 
Join Date: Feb 2004
Location: Warsaw, Poland
Posts: 8
Don't compare MBAFF vs frame mode in interlaced contents. What you can do is to compare:
1. MBAFF vs AFF in interlaced contents,
2. MBAFF vs FRAME in progressive ones

In the first case it really depends on the content. As you've mentioned MBAFF (or more generally macroblock adaptive coding) is widely used in a professional domain (e.g. sattelite broadcasters), but first of all it's because of the uncertain nature of TV conent: some parts of the screen may be interlaced, some may not (e.g. anchorman + bottom ticker + some on-screen graphs, text, etc.). In such a case MBAFF will give overally better coding performance compared to just AFF (interlaced or progressive).

In the second case you'll definatelly lose some bins/bits for coding of the MBAFF modes compared to just plain progressive, since making this decision on a mb level is not necessary and is a waste of bins.
Gusto is offline   Reply With Quote
Old 1st July 2005, 10:08   #11  |  Link
hworldjj
Registered User
 
Join Date: Sep 2004
Posts: 17
Quote:
Originally Posted by Gusto
Don't compare MBAFF vs frame mode in interlaced contents. What you can do is to compare:
1. MBAFF vs AFF in interlaced contents,
2. MBAFF vs FRAME in progressive ones

In the first case it really depends on the content. As you've mentioned MBAFF (or more generally macroblock adaptive coding) is widely used in a professional domain (e.g. sattelite broadcasters), but first of all it's because of the uncertain nature of TV conent: some parts of the screen may be interlaced, some may not (e.g. anchorman + bottom ticker + some on-screen graphs, text, etc.). In such a case MBAFF will give overally better coding performance compared to just AFF (interlaced or progressive).

In the second case you'll definatelly lose some bins/bits for coding of the MBAFF modes compared to just plain progressive, since making this decision on a mb level is not necessary and is a waste of bins.
First, it's meanless to use MBAFF or PAFF for progressive movies. Second the point is that MBAFF is always better than PAFF in most of cases due to the essence of natual videos, where only part of pictures needed to be encoded with interlaced mode.

hworldjj
hworldjj is offline   Reply With Quote
Old 1st July 2005, 10:13   #12  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Actually, if every decision in the encoder was made in RD, MBAFF would be better than PAFF on interlaced content, and than progressive encoding on progressive content.
Manao is offline   Reply With Quote
Old 9th October 2006, 22:03   #13  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779
is it still considered to be a valid statement that mbaff is better than pure progressive encoding on pure progressive content?

if yes, why? ^^
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 9th October 2006, 22:13   #14  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
It's a valid statement when the video has a lot of high vertical frequencies ( horizontal stripes for example ). A "classic" example is foreman. On that progressive video, roughly 10 % of the macroblocks will be encoded as interlaced. Of course, foreman isn't the average video ( it's highly aliased ), and it's definitively not representative of most of the DVD.

On more common videos, the additionnal 1 bit per 2 macroblock will, with CABAC, be transformed in 1/5 to 1/10th of a bit per 2 macroblock, so the overhead will be quite small, while interlaced encoding might still kick in if high vertical frequencies show up. But it would be a closer call ( and progressive might still win ).
__________________
Manao is offline   Reply With Quote
Old 9th October 2006, 22:14   #15  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,393
My intuition is: no.
There will be a very few macroblocks where interlaced coding is better than progressive coding. i.e. if the content happens to contain textures that look combed.
But this is offset by the costs of mbaff: a fraction of a bit per macroblock to say "this block is progressive", and odd rows are unable to use the top-right neighbor for mv or intra prediction, and the resolution has to be mod32 (rather than the normal mod16), and the characteristic quantization artifacts of field coding tend to add combs (though this might be hidden if field coding is used only in the blocks that already contain such features).

Foreman isn't just aliased, it's deinterlaced. So it doesn't count as even abnormal progressive content.

Last edited by akupenguin; 9th October 2006 at 22:20.
akupenguin is offline   Reply With Quote
Old 9th October 2006, 22:44   #16  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779


btw would it be possible to losslessly convert from a mbaff stream that contains only progressive macroblocks to a real progressive stream?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 9th October 2006, 22:58   #17  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,393
Yes. But it's not as trivial as cabac<->cavlc, since you have to reorder the macroblocks and reconsider which ones use skip/direct modes vs coded mvs.
akupenguin is offline   Reply With Quote
Old 10th October 2006, 05:19   #18  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Isnt there an issue with intra prediction ?
__________________
Manao is offline   Reply With Quote
Old 10th October 2006, 06:02   #19  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,393
Oops, yes. If you use diagonal-down-left mode on the top-right sub-block of an intra macroblock in an odd row, mbaff changes the prediction algorithm since the top-right neighbor is unavailable.
akupenguin is offline   Reply With Quote
Old 11th October 2006, 21:07   #20  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,779
damn, i hoped that it would be possible to convert the hdtv avc mbaff broadcasts to pure progressive (with progressive content)

i kinda start to prefer paff over mbaff, cause with paff its possible to send pure progressive streams as progressive
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond 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 20:46.


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