TV 的解析

除了不要把這裡當作電腦軟硬體診療室之外,什麼都可以聊!

版主: DearHoney

頭像
kouyoumin
神人
文章: 1612
註冊時間: 2001-01-05 08:00
來自: 中正紀念堂
聯繫:

文章 kouyoumin »

我是參考取樣頻率12+27/99MHz / 13.5MHz = 10/11得來的 ^^;
至於"不是非常準"是參考silky樣的發現
節約用電 - VIA EPIA CN運作中
Silky
大師
文章: 82
註冊時間: 2001-01-09 08:00
來自: Phantasmagoria

文章 Silky »

(搖手搖手)那個不是我的發現,是那個網站作者的發現,我只是轉述過來而已。

MPEG-1 standard 裡面關於 Pixel Aspect Ratio 的定義是一件大慘劇,把它忘了吧 :P
實際上處理的時候,我們只是根據 720/1.125 = 640,得到 640x480,4:3 的播放比例,
知道最後要顯示成 4:3 的播放比例,而不是真的按照 pel_aspect_ratio 欄位定義的數字來做 resize,
這樣直接 resize 是錯的。
原始影像是 Rec.601 Pixels,也就是取樣的時候的長寬比例是 11/10 for NTSC,54/59 for PAL,
所以我們處理的時候,也是按照原影像的 Sample Aspect Ratio 來做處理,
而不是按照 MPEG-1 Committee 自創的 pel_aspect_ratio 來處理。

取樣時寬度比高度多取樣 11/10 倍
640 * 11/10 = 704
所以 [SAR(PAR) 11/10] [DAR 4:3] 的 704x480,等於 [SAR 1:1] [DAR 4:3] 的 640x480。

DVD/DV 等 720x480 的訊源,播放時要左右共切 16 pixels,變成 704x480,
再 resize 至 640x480 等 4:3 比例,比例才是正確的。

同理 352x240 的 VCD,[SAR 11/10] [DAR 4:3] 的 352x240,等於 [SAR 1:1] [DAR 4:3] 的 320x240
320 * 11/10 = 352
所以播放時直接 resize 至 320x240 等 4:3 比例就是正確的,千萬不要再左右補點。

擷取卡擷取下來 704x480 就是 4:3 的比例,如果要製作成 DVD,左右兩邊補點
(以壓縮的觀點來說,補在同一邊較好),補 16 pixels 變成 720x480 即可。
擷取卡能擷取 720x480,多出來的那 16 pixels 算是送的,顯示時也沒有實際作用,還是要切掉。
而且 720x480 也不一定是滿的,根據有效的取樣時間,通常兩邊還是會留下黑邊。

以上 11/10 for NTSC,54/59 for PAL 等數據,只是近似值,精確值是 79/72 和 117/128,
為了說明方便,故予簡略。

關於 MPEG-1 standard 的慘劇,可以看
http://www.mir.com/DMG/aspect.html

節錄當中的說明

The actual MPEG-1 specification specifies the following pixel aspect ratios:
  • 1.0950 for "CCIR Rec. 601, 525-line" images with frames of
    "711x487 at 4:3"
  • 0.9157 for "CCIR Rec. 601, 625-line" images with frames of
    "702x575 at 4:3"
These numbers are self-consistent, but otherwise rather contrived. They
should have just said "10:11 for CCIR Rec.601, 525-line" and "59:54 for
CCIR Rec.601, 625-line" since that is apparently what they meant
and that is how they are used.

According to the actual MPEG-2 specification, the video stream sequence
header specifies the intended display aspect ratio rather than the
pixel aspect ratios, from one of these choices:
  • 4:3
  • 16:9
  • 2.21:1
(Oh, and you can also specify "1:1 pixel aspect ratio".)
This is supposed to be an improvement over MPEG-1's contrived pixel aspect
ratio descriptions. It's not, because in practice, MPEG-2 sources are
720x480 or 720x576 with CCIR-601 pixels, which are slightly wider
than 4:3 or 16:9. So, as before, the actual numbers in the specification
don't mean very much.

還有這個網站的說明
http://www.lurkertech.com/lg/pixelaspect.html

節錄

Pixel Aspect in MPEG I and MPEG II

The sequence header of MPEG I video bitstreams contains an enumerated
field identifying the pixel aspect ratio of the video images. In rev
1 of ISO/IEC DIS 2-11172, the MPEG I committee assigned two of the 16
tokens for the aspect ratios of 525- and 625-line video.
Unfortunately, the values behind these tokens were not the 11/10 or
54/59 above. The MPEG committee derived the values from a fixed 4:3
frame aspect ratio times a canonical image height and width in pixels
which the committee seems to have made up. The pixel aspect ratio
does not and should not depend on the video bitstream image size in
pixels. The pixel aspect ratio is determined by the sampling grid of
the device capturing the video; you can capture many different image
sizes from the same grid.

In rev 2 of ISO/IEC DIS 2-11172, the committee changed the pixel
aspect ratios in the table, but sadly they still were not 11/10 or
54/59. The committee only changed the made-up canonical image
dimensions to other made-up canonical image dimensions.

Even more bizarrely, in both drafts, the committee decided to fill in
the 12 open slots in the pixel aspect ratio table with linear
interpolations and extrapolations of the 525- and 625-line values!
They topped it off with this conundrum:
"It is evident that the specification does not allow all possible pel
aspect ratios to be specified. We therefore presume that a certain
degree of tolerance is allowable. Encoders will convert the actual pel
aspect ratio to the nearest value in the table, and decoders
will display the decoded values to the nearest pel aspect ratio of
which they are capable."
Hopefully from this data you have learned not to trust the pixel
aspect ratio encoded in an MPEG I video bitstream.

The MPEG II committee discarded the MPEG I pixel aspect table. But
unfortunately it retained the notion that pixel aspect ratio depends
on encoded image size. Pixel aspect of an MPEG II video bitstream
sequence can be 1.0, or it can be specified in terms of a frame aspect
ratio times a ratio of the image height and width in pixels. The
frame aspect ratio can be a fixed value (4:3 or 16:9) or it can be
encoded in the bitstream as any two integers. Unlike MPEG I, it's
possible to twist the MPEG II paramers around in order to make them
say what they should originally have said: that the pixel aspect is
11/10 or 54/59. It's too bad that the committee didn't just offer
these as constants.

So I would watch out for the pixel aspect ratios encoded in all kinds
of MPEG. If you know that data came from non-square-sampled video,
use your own judgement.

最後關於播放比例的詳細說明,請參閱伊莉琴斯壓縮技術實驗室的精華區\r
http://bbs.irradiance.net/txtVersion/tr ... 532.A.html
http://bbs.irradiance.net/txtVersion/tr ... 411.A.html

關於 79/72 的 PAR 是怎麼來的,請參閱這個網站\r
http://www.uwasa.fi/~f76998/video/conversion/
hotball
神人
文章: 322
註冊時間: 2001-09-28 08:00
聯繫:

文章 hotball »

我看了 VCD 2.0 的規定,它是「建議」用 1:1.0950 和 1:0.9157。不過它並沒有解釋如果是否可以使用別的 pixel aspect ratio。

至於 MPEG-2 使用 DAR 雖然有其好處,但是也有很多問題。例如 720x480 和 704x480 都被 DVD 所支援,它們都應該使用 4:3 DAR 嗎?這樣應該還是有問題。所以 MPEG-4 又回到指定 pixel aspect ratio,而且可以自由指定,那就可以比較方便使用 NTSC 或 PAL 本來的 11:10 和 11:12 了(當然這兩個是已經事先定好的,所以是不需要自定… :P )。

以 MPEG-2 來說,像是 SVCD 的 video 使用 480x480(NTSC),並使用 4:3 DAR 和 16:9 DAR,但是在 still image 又同時支援 480x480 和 704x480,而且兩者都是使用 4:3 或 16:9 DAR,這就會讓人感到相當麻煩。

BT601(former CCIR 601)規定 13.5Mhz 4:2:2 的 encoding 方式,在 525 lines 60 fields/s 時,每 line 的總 sample 數是 858/429(Y/Cr/Cb),但在實際上有資料的只有 720/360。這可以用在 4:3 或 16:9 上面。
Silky
大師
文章: 82
註冊時間: 2001-01-09 08:00
來自: Phantasmagoria

文章 Silky »

hotball 樣 :)

是的,所以還是用 PAR 好。
MPEG-1 的慘劇,不是說使用 PAR 不好,而是 MPEG-1 的 PAR 不是應該的 11:10,
而是胡亂訂出了一堆 PAR,然而這些 PAR 不是真實使用的數據。
PAR 是由原始畫面取樣時決定的,不是由壓縮的影像像素的長寬比決定的,
MPEG-2 如果有 sequence_display_extension 資訊,PAR 甚至是由 display 的長寬比決定的,
簡直是胡來。
所以才會被人說是
It seems the original intent of MPEG / H.26x committees was to use "easier" numbers and definition for aspect ratio, but this actually only serves to create confusion. The moral of the story: do not blindly trust MPEG headers on aspect ratio issues. Instead, make your own educated judgement based on which kind of equipment you use, where the video is from, and how you actually want the conversion done. Most video is sampled at 13.5 MHz and converted directly - pixel-by-pixel - to these formats, regardless of what the headers nominally claim the aspect ratio to be.
MPEG-4 改回使用 PAR,而且數據正確,這樣才是可用的資訊。
自由指定的部分,長寬也都特別註明,par_width/par_height 是 the horizontal/vertical size of pixel aspect ratio.,不是影像像素的 size,更不是顯示播放的 size,可喜可賀,這次終於對了 :P
回覆文章