001package net.bramp.ffmpeg.info;
002
003import org.apache.commons.lang3.builder.EqualsBuilder;
004import org.apache.commons.lang3.builder.HashCodeBuilder;
005
006public class PixelFormat {
007  private final String name;
008  private final int numberOfComponents;
009  private final int bitsPerPixel;
010
011  private final boolean canDecode;
012  private final boolean canEncode;
013  private final boolean hardwareAccelerated;
014  private final boolean palettedFormat;
015  private final boolean bitstreamFormat;
016
017  public PixelFormat(String name, int numberOfComponents, int bitsPerPixel, String flags) {
018    this.name = name;
019    this.numberOfComponents = numberOfComponents;
020    this.bitsPerPixel = bitsPerPixel;
021
022    this.canDecode = flags.charAt(0) == 'I';
023    this.canEncode = flags.charAt(1) == 'O';
024    this.hardwareAccelerated = flags.charAt(2) == 'H';
025    this.palettedFormat = flags.charAt(3) == 'P';
026    this.bitstreamFormat = flags.charAt(4) == 'B';
027  }
028
029  @Override
030  public String toString() {
031    return name;
032  }
033
034  @Override
035  public boolean equals(Object obj) {
036    return EqualsBuilder.reflectionEquals(this, obj);
037  }
038
039  @Override
040  public int hashCode() {
041    return HashCodeBuilder.reflectionHashCode(this);
042  }
043
044  public String getName() {
045    return name;
046  }
047
048  public int getBitsPerPixel() {
049    return bitsPerPixel;
050  }
051
052  public int getNumberOfComponents() {
053    return numberOfComponents;
054  }
055
056  public boolean canEncode() {
057    return canEncode;
058  }
059
060  public boolean canDecode() {
061    return canDecode;
062  }
063
064  public boolean isHardwareAccelerated() {
065    return hardwareAccelerated;
066  }
067
068  public boolean isPalettedFormat() {
069    return palettedFormat;
070  }
071
072  public boolean isBitstreamFormat() {
073    return bitstreamFormat;
074  }
075}