A Adam Learning
Back to notes
9618-AS-01-03Chapter 1Section 1.3comprehensive

1.3 Compression 数据压缩

Review the exact wording students need for this knowledge point, then open a filtered question list when ready to practise.

Find questions for 9618-AS-01-03

Syllabus learning goals 考纲学习目标

完成本节后,学生需要能够:

  • 解释为什么需要 compression,并结合实际场景说明其用途。
  • 区分 lossy 与 lossless compression,并为给定场景选择合适方法。
  • 解释 text file、bitmap image、vector graphic 和 sound file 可以如何压缩。
  • 解释 run-length encoding (RLE) 的过程、适用场景和限制。
压缩简答题的核心不是只写 “file size is smaller”,而是继续说明较小文件对 storage、transmission time、bandwidth、data allowance 或 buffering 的具体影响。

1 Why compression is needed 为什么压缩

Compression 使用一种编码方法减少表示文件所需的数据量。

Direct effects

  • The file uses less storage space.
  • Transmission/upload/download time is reduced.
  • Less bandwidth is required/used.
  • Less data allowance is consumed.
  • 对 real-time streaming,较少数据也可以 reduce buffering

Turn an effect into a user benefit

题目常要求 explain benefits,而不只是 state effects。应补充第二层结果:

  • Less storage is used, so more files can be stored
  • Transmission time is reduced, so the user waits less time for the file to arrive
  • Less bandwidth is used, so other transmissions are less affected
  • A smaller attachment is less likely to exceed an email attachment-size limit。

Three-mark answer pattern

The compressed file uses less storage space, so the user can store more files. It contains less data, so transmission time is reduced. It also requires less bandwidth, so other network traffic is less affected.

不要把 “smaller file”“less storage”和“more files can be stored”当作三个完全独立的原因;后两者最好写成一条因果链。

2 When compression may not be needed 何时不需要

在具体场景中,文件可能不需要压缩:

  • 使用 dedicated connection,不与其他设备分享 bandwidth。
  • Connection 足够快,可以及时传输原始数据。
  • File size 本来已经很小。
  • 数据只即时播放、不保存,因此 storage 不是限制。
  • 需要保留完整质量,而系统资源足够。

作答必须与题目环境对应,不能只写 “compression takes time”。

3 Lossless compression 无损压缩

Lossless compression 的关键定义:

  • No original data is permanently lost.
  • The original file can be recreated exactly after decompression.

适合 text、program files、database records 等不能丢失任何内容的数据。若 text 丢失字符,文件可能 be corrupted / no longer make sense

Mark-scheme answer pattern

Lossless compression is appropriate because all the original data is required and the file can be recreated exactly. If characters were removed, the text could be corrupted or no longer make sense.

4 Lossy compression 有损压缩

Lossy compression 会永久移除部分数据:

  • Some original data is permanently removed.
  • The original file cannot be recreated exactly.
  • 通常能比 lossless 获得更大的 file-size reduction,但质量会下降。

适合 photograph、audio 和 video,因为可以移除人眼或人耳不容易察觉的数据。

Why lossy may suit images or streaming

  • Removed detail may not be noticeable to the human eye/ear
  • File size can be reduced more than with lossless compression。
  • Less bandwidth is required and buffering can be reduced。
  • Upload/download or real-time transmission becomes faster。

Scenario justification

Lossy compression is suitable for real-time video because it reduces the file size more than lossless compression, so less bandwidth is required and buffering is reduced. Some image detail can be removed without noticeably affecting the viewer's experience.

选择 lossless 也可能合理,但 justification 必须与场景一致,例如用户要求保存原始质量且 bandwidth 足够。

5 Run-length encoding (RLE)

RLE 是 lossless compression。它寻找 consecutive repeated values,再用一个 value 和 repetition count 代替整段重复数据。

Bitmap example

Original pixels:  Blue Blue Blue Blue Blue Red Red
RLE:              5 Blue, 2 Red

Mark-scheme process [2]

  • Identify a sequence of consecutive identical colours/pixels.
  • Store one colour/pixel value and the number of times it repeats.

必须写 consecutive。RLE 不能把文件中位置分散的相同颜色合并成同一段。

Text example

Original: AAAAABBBCC
RLE:      5A3B2C

描述 text compression 时可写:

  • Use run-length encoding (RLE)
  • Repeated sequences of the same character are replaced。
  • Store one copy of the character and a count of the repetitions

6 When RLE can increase file size RLE 的限制

RLE 只在文件有较长重复序列时有效。若颜色频繁变化:

Original: Red Green Blue
RLE:      1 Red, 1 Green, 1 Blue

每个原始 value 之外还要存 count 1,反而增加数据量。

Three-point explanation

  • RLE stores a colour/value and the number of consecutive repetitions。
  • The image may contain few or no long sequences of the same colour。
  • A count of 1 must then be stored for many pixels, adding data rather than reducing it

Photographs 通常包含大量细微变化,RLE 未必有效;大面积纯色的 simple graphic 更适合 RLE。

7 Compressing different file types 不同文件类型

Text files

  • 使用 lossless 方法,因为所有 characters 都必须保留。
  • RLE 可压缩重复 characters 或 spaces。
  • 也可使用 dictionary-based encoding:重复 words/patterns 用较短 reference 代替;解压时必须能精确恢复。

Bitmap images

  • Lossless:RLE 存储 repeated consecutive pixel colours;适合大面积相同颜色。
  • Lossy:降低 colour depth/image resolution,或移除人眼不易察觉的 detail;通常 file-size reduction 更大。

Vector graphics

  • 删除不需要的 metadata 或冗余 object descriptions。
  • 重复使用的 objects/properties 可存储一次,再用 references 表示多次使用。
  • 若必须精确重建 drawing objects 与 properties,应使用 lossless 方法。

Sound files

Lossy sound compression 可以:

  • Decrease the sampling rate,因此每秒存储 fewer samples。
  • Decrease the sampling resolution,因此每个 sample 使用 fewer bits。
  • Remove frequencies/sounds outside or masked from normal human hearing。

每个方法都必须补充“为什么 file size 下降”。例如:

Decrease the sampling rate, so fewer samples per second are stored, reducing the amount of data.

8 Choosing the method 选择方法

SituationLikely choiceReasoning
Text document or programLosslessEvery character/instruction is required; original must be recreated exactly.
Photograph on a websiteLossyLarge reduction; small quality loss may not be noticed; faster download and less bandwidth.
Master copy of an imageLosslessExact original quality/data must be retained.
Real-time video streamOften lossyLess bandwidth and buffering; some quality loss may be acceptable.
Simple image with long runs of one colourRLE losslessLong consecutive repeated pixel values can be replaced efficiently.
Photograph with frequent colour changesRLE may be poorMany runs have count 1, adding overhead.

题目允许多种合理选择时,分数通常取决于 justification 是否与选择一致,而不是只看勾选 lossy 或 lossless。

9 Exam-answer checklist 真题检查表

  • 是否明确写了 original data 能否精确恢复?
  • 是否把 compression type 与场景需求联系起来?
  • 是否从 smaller file 继续写出 storage、time、bandwidth 或 buffering 的后果?
  • RLE 是否写了 consecutive identical values?
  • 是否同时写了 stored value 和 repetition count?
  • 是否说明 RLE 在 count 多为 1 时可能增加文件大小?
  • 音频压缩是否写出 fewer samples 或 fewer bits per sample,而不是只写 lower quality?
  • Explain 题是否形成完整的 cause-and-effect chain?

本材料依据 9618 syllabus 1.3 的三项要求,并综合本页所列 2021-2025 past-paper questions 及 mark schemes。示例围绕评分方案中反复出现的 storage、transmission、bandwidth、exact reconstruction 与 RLE wording 组织。

Practice This Knowledge Point

Open the question bank with this knowledge code already filled in. The filtered list will show matching questions for this note.

Open filtered practice
Source questions used